Message ID | 20211202070658.2164977-1-raj.khem@gmail.com |
---|---|
State | New |
Headers | show |
Series | Remove bash dependency for nscd init script | expand |
* Khem Raj via Libc-alpha: > The nscd init script uses #! /bin/bash but only really uses one bashism > (translated strings), so remove them and switch the shell to #!/bin/sh. > > Signed-off-by: Ross Burton <ross.burton@intel.com> > Signed-off-by: Khem Raj <raj.khem@gmail.com> > --- > nscd/nscd.init | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/nscd/nscd.init b/nscd/nscd.init > index a882da7d8b..b02986ec15 100644 > --- a/nscd/nscd.init > +++ b/nscd/nscd.init > @@ -1,4 +1,4 @@ > -#!/bin/bash > +#!/bin/sh > # > # nscd: Starts the Name Switch Cache Daemon > # > @@ -49,7 +49,7 @@ prog=nscd > start () { > [ -d /var/run/nscd ] || mkdir /var/run/nscd > [ -d /var/db/nscd ] || mkdir /var/db/nscd > - echo -n $"Starting $prog: " > + echo -n "Starting $prog: " I believe “echo -n” is still a bashim. The current-POSIX portable solution is to use printf. But “echo -n” might actually be *more* portable than printf in practice. Thanks, Florian
On Thu, Dec 2, 2021 at 7:40 AM Florian Weimer <fweimer@redhat.com> wrote: > > * Khem Raj via Libc-alpha: > > > The nscd init script uses #! /bin/bash but only really uses one bashism > > (translated strings), so remove them and switch the shell to #!/bin/sh. > > > > Signed-off-by: Ross Burton <ross.burton@intel.com> > > Signed-off-by: Khem Raj <raj.khem@gmail.com> > > --- > > nscd/nscd.init | 14 +++++++------- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/nscd/nscd.init b/nscd/nscd.init > > index a882da7d8b..b02986ec15 100644 > > --- a/nscd/nscd.init > > +++ b/nscd/nscd.init > > @@ -1,4 +1,4 @@ > > -#!/bin/bash > > +#!/bin/sh > > # > > # nscd: Starts the Name Switch Cache Daemon > > # > > @@ -49,7 +49,7 @@ prog=nscd > > start () { > > [ -d /var/run/nscd ] || mkdir /var/run/nscd > > [ -d /var/db/nscd ] || mkdir /var/db/nscd > > - echo -n $"Starting $prog: " > > + echo -n "Starting $prog: " > > I believe “echo -n” is still a bashim. The current-POSIX portable > solution is to use printf. But “echo -n” might actually be *more* > portable than printf in practice. The fix is used to make it work with busybox shell and therefore not tried to clean full bash specific stuff. > > Thanks, > Florian >
On Thu, Dec 2, 2021, at 10:40 AM, Florian Weimer via Libc-alpha wrote: > * Khem Raj via Libc-alpha: > >> The nscd init script uses #! /bin/bash but only really uses one bashism >> (translated strings), so remove them and switch the shell to #!/bin/sh > > I believe “echo -n” is still a bashim. The current-POSIX portable > solution is to use printf. But “echo -n” might actually be *more* > portable than printf in practice. printf(1) is reliable enough in practice that autoconf scripts now use it unconditionally (as of 2.70). zw
* Khem Raj: > On Thu, Dec 2, 2021 at 7:40 AM Florian Weimer <fweimer@redhat.com> wrote: >> >> * Khem Raj via Libc-alpha: >> >> > The nscd init script uses #! /bin/bash but only really uses one bashism >> > (translated strings), so remove them and switch the shell to #!/bin/sh. >> > >> > Signed-off-by: Ross Burton <ross.burton@intel.com> >> > Signed-off-by: Khem Raj <raj.khem@gmail.com> >> > --- >> > nscd/nscd.init | 14 +++++++------- >> > 1 file changed, 7 insertions(+), 7 deletions(-) >> > >> > diff --git a/nscd/nscd.init b/nscd/nscd.init >> > index a882da7d8b..b02986ec15 100644 >> > --- a/nscd/nscd.init >> > +++ b/nscd/nscd.init >> > @@ -1,4 +1,4 @@ >> > -#!/bin/bash >> > +#!/bin/sh >> > # >> > # nscd: Starts the Name Switch Cache Daemon >> > # >> > @@ -49,7 +49,7 @@ prog=nscd >> > start () { >> > [ -d /var/run/nscd ] || mkdir /var/run/nscd >> > [ -d /var/db/nscd ] || mkdir /var/db/nscd >> > - echo -n $"Starting $prog: " >> > + echo -n "Starting $prog: " >> >> I believe “echo -n” is still a bashim. The current-POSIX portable >> solution is to use printf. But “echo -n” might actually be *more* >> portable than printf in practice. > > The fix is used to make it work with busybox shell and therefore not > tried to clean full bash specific stuff. Fair enough, incremental changes are welcome. But please adjust the commit message. 8-) Thanks, Florian
diff --git a/nscd/nscd.init b/nscd/nscd.init index a882da7d8b..b02986ec15 100644 --- a/nscd/nscd.init +++ b/nscd/nscd.init @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # # nscd: Starts the Name Switch Cache Daemon # @@ -49,7 +49,7 @@ prog=nscd start () { [ -d /var/run/nscd ] || mkdir /var/run/nscd [ -d /var/db/nscd ] || mkdir /var/db/nscd - echo -n $"Starting $prog: " + echo -n "Starting $prog: " daemon /usr/sbin/nscd RETVAL=$? echo @@ -58,7 +58,7 @@ start () { } stop () { - echo -n $"Stopping $prog: " + echo -n "Stopping $prog: " /usr/sbin/nscd -K RETVAL=$? if [ $RETVAL -eq 0 ]; then @@ -67,9 +67,9 @@ stop () { # a non-privileged user rm -f /var/run/nscd/nscd.pid rm -f /var/run/nscd/socket - success $"$prog shutdown" + success "$prog shutdown" else - failure $"$prog shutdown" + failure "$prog shutdown" fi echo return $RETVAL @@ -103,13 +103,13 @@ case "$1" in RETVAL=$? ;; force-reload | reload) - echo -n $"Reloading $prog: " + echo -n "Reloading $prog: " killproc /usr/sbin/nscd -HUP RETVAL=$? echo ;; *) - echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}" + echo "Usage: $0 {start|stop|status|restart|reload|condrestart}" RETVAL=1 ;; esac