Make bootscripts more POSIX compliant

Dan Nicholson dbn.lists at gmail.com
Mon Feb 19 23:52:28 PST 2007


On 2/19/07, Bruce Dubbs <bruce.dubbs at gmail.com> wrote:
> Dan Nicholson wrote:
>
> > First patch is to eliminated "echo -[en]" since it's not always
> > supported by POSIX shells. I chose to use printf since it was a
> > builtin in dash. I didn't notice until later that it's not mentioned
> > in POSIX. And the executable printf is in /usr/bin. We can maintain
> > the same "echo -[en]" syntax by switching in /bin/echo everywhere,
> > too.
>
> I prefer using /bin/echo.  I wonder if there would be a test to see if
> echo -[en] works or not and then:
>
> if (works) ECHO=echo
> else ECHO=/bin/echo
>
> and then use $ECHO everywhere.

Excellent idea. What's below seems to work. A more complete test can
be found near the beginning of any autoconf generated configure
script, but it doesn't really fit our usage pattern.

case `echo -en "test"` in
        -en*)
                ECHO=/bin/echo
                ;;
        *)
                ECHO=echo
                ;;
esac

--
Dan



More information about the lfs-dev mailing list