public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Remove bash dependency for nscd init script
@ 2021-12-02  7:06 Khem Raj
  2021-12-02  7:06 ` [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its empty Khem Raj
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Khem Raj @ 2021-12-02  7:06 UTC (permalink / raw)
  To: libc-alpha; +Cc: Khem Raj, Ross Burton

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: "
     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
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its empty
  2021-12-02  7:06 [PATCH] Remove bash dependency for nscd init script Khem Raj
@ 2021-12-02  7:06 ` Khem Raj
  2021-12-03  3:44   ` Mike Frysinger
  2021-12-02  7:06 ` [PATCH] timezone: re-written tzselect as posix sh Khem Raj
  2021-12-02 15:40 ` [PATCH] Remove bash dependency for nscd init script Florian Weimer
  2 siblings, 1 reply; 12+ messages in thread
From: Khem Raj @ 2021-12-02  7:06 UTC (permalink / raw)
  To: libc-alpha; +Cc: Khem Raj, Matthieu Crapet

This ensures that it can be set in build environment

Signed-off-by: Matthieu Crapet <Matthieu.Crapet@ingenico.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 sysdeps/gnu/configure    | 2 +-
 sysdeps/gnu/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/gnu/configure b/sysdeps/gnu/configure
index c15d1087e8..37cc983f2a 100644
--- a/sysdeps/gnu/configure
+++ b/sysdeps/gnu/configure
@@ -32,6 +32,6 @@ case "$prefix" in
   else
     libc_cv_localstatedir=$localstatedir
    fi
-  libc_cv_rootsbindir=/sbin
+  test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin
   ;;
 esac
diff --git a/sysdeps/gnu/configure.ac b/sysdeps/gnu/configure.ac
index 634fe4de2a..3db1697f4f 100644
--- a/sysdeps/gnu/configure.ac
+++ b/sysdeps/gnu/configure.ac
@@ -21,6 +21,6 @@ case "$prefix" in
   else
     libc_cv_localstatedir=$localstatedir
    fi
-  libc_cv_rootsbindir=/sbin
+  test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin
   ;;
 esac
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] timezone: re-written tzselect as posix sh
  2021-12-02  7:06 [PATCH] Remove bash dependency for nscd init script Khem Raj
  2021-12-02  7:06 ` [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its empty Khem Raj
@ 2021-12-02  7:06 ` Khem Raj
  2021-12-02 15:38   ` Florian Weimer
                     ` (2 more replies)
  2021-12-02 15:40 ` [PATCH] Remove bash dependency for nscd init script Florian Weimer
  2 siblings, 3 replies; 12+ messages in thread
From: Khem Raj @ 2021-12-02  7:06 UTC (permalink / raw)
  To: libc-alpha; +Cc: Khem Raj, Hongxu Jia

To avoid the bash dependency.

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 timezone/tzselect.ksh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh
index 18fce27e24..7705df83d7 100755
--- a/timezone/tzselect.ksh
+++ b/timezone/tzselect.ksh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Ask the user about the time zone, and output the resulting TZ value to stdout.
 # Interact with the user via stderr and stdin.
 
@@ -34,7 +34,7 @@ REPORT_BUGS_TO=tz@iana.org
 
 # Specify default values for environment variables if they are unset.
 : ${AWK=awk}
-: ${TZDIR=`pwd`}
+: ${TZDIR=$(pwd)}
 
 # Output one argument as-is to standard output.
 # Safer than 'echo', which can mishandle '\' or leading '-'.
-- 
2.34.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] timezone: re-written tzselect as posix sh
  2021-12-02  7:06 ` [PATCH] timezone: re-written tzselect as posix sh Khem Raj
@ 2021-12-02 15:38   ` Florian Weimer
  2021-12-02 16:15     ` Khem Raj
  2021-12-02 18:55   ` Joseph Myers
  2021-12-02 21:30   ` Paul Eggert
  2 siblings, 1 reply; 12+ messages in thread
From: Florian Weimer @ 2021-12-02 15:38 UTC (permalink / raw)
  To: Khem Raj via Libc-alpha; +Cc: Khem Raj, Hongxu Jia

* Khem Raj via Libc-alpha:

> To avoid the bash dependency.
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
>  timezone/tzselect.ksh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh
> index 18fce27e24..7705df83d7 100755
> --- a/timezone/tzselect.ksh
> +++ b/timezone/tzselect.ksh
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/bin/sh
>  # Ask the user about the time zone, and output the resulting TZ value to stdout.
>  # Interact with the user via stderr and stdin.
>  
> @@ -34,7 +34,7 @@ REPORT_BUGS_TO=tz@iana.org
>  
>  # Specify default values for environment variables if they are unset.
>  : ${AWK=awk}
> -: ${TZDIR=`pwd`}
> +: ${TZDIR=$(pwd)}
>  
>  # Output one argument as-is to standard output.
>  # Safer than 'echo', which can mishandle '\' or leading '-'.

Is this really a bashism?  I'm surprised.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Remove bash dependency for nscd init script
  2021-12-02  7:06 [PATCH] Remove bash dependency for nscd init script Khem Raj
  2021-12-02  7:06 ` [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its empty Khem Raj
  2021-12-02  7:06 ` [PATCH] timezone: re-written tzselect as posix sh Khem Raj
@ 2021-12-02 15:40 ` Florian Weimer
  2021-12-02 15:54   ` Khem Raj
  2021-12-02 17:40   ` Zack Weinberg
  2 siblings, 2 replies; 12+ messages in thread
From: Florian Weimer @ 2021-12-02 15:40 UTC (permalink / raw)
  To: Khem Raj via Libc-alpha; +Cc: Khem Raj, Ross Burton

* 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Remove bash dependency for nscd init script
  2021-12-02 15:40 ` [PATCH] Remove bash dependency for nscd init script Florian Weimer
@ 2021-12-02 15:54   ` Khem Raj
  2021-12-02 18:57     ` Florian Weimer
  2021-12-02 17:40   ` Zack Weinberg
  1 sibling, 1 reply; 12+ messages in thread
From: Khem Raj @ 2021-12-02 15:54 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Khem Raj via Libc-alpha, Ross Burton

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
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] timezone: re-written tzselect as posix sh
  2021-12-02 15:38   ` Florian Weimer
@ 2021-12-02 16:15     ` Khem Raj
  0 siblings, 0 replies; 12+ messages in thread
From: Khem Raj @ 2021-12-02 16:15 UTC (permalink / raw)
  To: Florian Weimer; +Cc: Khem Raj via Libc-alpha, Hongxu Jia

On Thu, Dec 2, 2021 at 7:38 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * Khem Raj via Libc-alpha:
>
> > To avoid the bash dependency.
> >
> > Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> > Signed-off-by: Khem Raj <raj.khem@gmail.com>
> > ---
> >  timezone/tzselect.ksh | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/timezone/tzselect.ksh b/timezone/tzselect.ksh
> > index 18fce27e24..7705df83d7 100755
> > --- a/timezone/tzselect.ksh
> > +++ b/timezone/tzselect.ksh
> > @@ -1,4 +1,4 @@
> > -#!/bin/bash
> > +#!/bin/sh
> >  # Ask the user about the time zone, and output the resulting TZ value to stdout.
> >  # Interact with the user via stderr and stdin.
> >
> > @@ -34,7 +34,7 @@ REPORT_BUGS_TO=tz@iana.org
> >
> >  # Specify default values for environment variables if they are unset.
> >  : ${AWK=awk}
> > -: ${TZDIR=`pwd`}
> > +: ${TZDIR=$(pwd)}
> >
> >  # Output one argument as-is to standard output.
> >  # Safer than 'echo', which can mishandle '\' or leading '-'.
>
> Is this really a bashism?  I'm surprised.

you are right. I tested it on bash/dash/zsh/ash it works as expected.
Let me find
the real reason for this patch and come back.

>
> Thanks,
> Florian
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Remove bash dependency for nscd init script
  2021-12-02 15:40 ` [PATCH] Remove bash dependency for nscd init script Florian Weimer
  2021-12-02 15:54   ` Khem Raj
@ 2021-12-02 17:40   ` Zack Weinberg
  1 sibling, 0 replies; 12+ messages in thread
From: Zack Weinberg @ 2021-12-02 17:40 UTC (permalink / raw)
  To: Florian Weimer, Florian Weimer; +Cc: Ross Burton

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] timezone: re-written tzselect as posix sh
  2021-12-02  7:06 ` [PATCH] timezone: re-written tzselect as posix sh Khem Raj
  2021-12-02 15:38   ` Florian Weimer
@ 2021-12-02 18:55   ` Joseph Myers
  2021-12-02 21:30   ` Paul Eggert
  2 siblings, 0 replies; 12+ messages in thread
From: Joseph Myers @ 2021-12-02 18:55 UTC (permalink / raw)
  To: Khem Raj; +Cc: libc-alpha, Hongxu Jia

tzselect.ksh is supposed to be taken verbatim from upstream tzcode, not 
locally modified.  See timezone/README.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] Remove bash dependency for nscd init script
  2021-12-02 15:54   ` Khem Raj
@ 2021-12-02 18:57     ` Florian Weimer
  0 siblings, 0 replies; 12+ messages in thread
From: Florian Weimer @ 2021-12-02 18:57 UTC (permalink / raw)
  To: Khem Raj; +Cc: Khem Raj via Libc-alpha, Ross Burton

* 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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] timezone: re-written tzselect as posix sh
  2021-12-02  7:06 ` [PATCH] timezone: re-written tzselect as posix sh Khem Raj
  2021-12-02 15:38   ` Florian Weimer
  2021-12-02 18:55   ` Joseph Myers
@ 2021-12-02 21:30   ` Paul Eggert
  2 siblings, 0 replies; 12+ messages in thread
From: Paul Eggert @ 2021-12-02 21:30 UTC (permalink / raw)
  To: Khem Raj; +Cc: Hongxu Jia, libc-alpha

On 12/1/21 23:06, Khem Raj via Libc-alpha wrote:
> To avoid the bash dependency.

A better way to avoid any Bash dependency would be to change 
timezone/Makefile's $(objpfx)tzselect rule to add a line like this:

    -e 's|#!/bin/bash|#!$(KSHELL)|g' \

where KSHELL is suitably defined for your platform. This is what the 
upstream (tzcode) Makefile does, and doing it this way would mean that 
tzselect.ksh could stay identical with upstream.

For KSHELL it's better to use Bash or some other Korn-compatible shell 
if available, since tzselect takes advantage of ksh-style 'select' 
commands (when the shell supports 'select') to have a somewhat better UI.


> -: ${TZDIR=`pwd`}
> +: ${TZDIR=$(pwd)}

This part of the patch is not relevant to any Bash dependency, since the 
form with `` should be supported by any POSIX shell.

That being said, nowadays tzselect.ksh could be streamlined a bit since 
we no longer need to worry about compatibility with Solaris 9 sh. I'll 
try to kick free some time to do that upstream.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its empty
  2021-12-02  7:06 ` [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its empty Khem Raj
@ 2021-12-03  3:44   ` Mike Frysinger
  0 siblings, 0 replies; 12+ messages in thread
From: Mike Frysinger @ 2021-12-03  3:44 UTC (permalink / raw)
  To: Khem Raj; +Cc: libc-alpha, Matthieu Crapet

[-- Attachment #1: Type: text/plain, Size: 159 bytes --]

On 01 Dec 2021 23:06, Khem Raj via Libc-alpha wrote:
> +  test -n "$libc_cv_rootsbindir" || libc_cv_rootsbindir=/sbin

: "${libc_cv_rootsbindir:=/sbin}"
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-12-03  3:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02  7:06 [PATCH] Remove bash dependency for nscd init script Khem Raj
2021-12-02  7:06 ` [PATCH] sysdeps/gnu/configure.ac: Set libc_cv_rootsbindir only if its empty Khem Raj
2021-12-03  3:44   ` Mike Frysinger
2021-12-02  7:06 ` [PATCH] timezone: re-written tzselect as posix sh Khem Raj
2021-12-02 15:38   ` Florian Weimer
2021-12-02 16:15     ` Khem Raj
2021-12-02 18:55   ` Joseph Myers
2021-12-02 21:30   ` Paul Eggert
2021-12-02 15:40 ` [PATCH] Remove bash dependency for nscd init script Florian Weimer
2021-12-02 15:54   ` Khem Raj
2021-12-02 18:57     ` Florian Weimer
2021-12-02 17:40   ` Zack Weinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).