K.S. Bhaskar on 21 Apr 2010 14:05:53 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] portable echo (was: Re: Shell scripting?)


On Wed, Apr 21, 2010 at 3:33 PM, JP Vossen <jp@jpsdomain.org> wrote:
>> Date: Wed, 21 Apr 2010 12:46:12 -0400
>> From: "K.S. Bhaskar" <ksbhaskar@gmail.com>
>
> [...]
>> # echo and options
>> ECHO=/bin/echo
>> ECHO_OPTIONS=""
>> #Linux honors escape sequence only when run with -e
>  > if [ "Linux" = "`uname -s`" ] ; then ECHO_OPTIONS="-e" ; fi
> [...]
>
> Yes, giant PITA.  echo is not POSIX...but printf [1] is...
>
> ### Bad, not portable, not POSIX:
>        echo ...
>
> ### "Good," portable, POSIX:
>        printf "%b\n" ...
>
>
> It's a little more typing than 'echo', but a lot less that the other
> portability solutions and so far has worked for me in practice.  Caveat,
> I really don't run much on non-Linux anymore...  I'll be interested to
> hear if that works as well as I think it does.

[KSB] printf seems to be there on the UNIX/Linux systems I have used
recently.  I'll consider printf in future.  I was not aware of it.
Than

> <sidebar>
> I recommend you *not* develop on Linux if you need portable shell
> scripts.  Linux & the GNU tools are *too* useful and friendly and
> helpful.  Even if you know what you are doing, you'll still have issues.
>  Find the oldest, crappiest system you need to run on, and develop (or
> at least alpha test) on that.  Odds are that it'll be a lot easier to
> port forward to Linux than backwards from Linux to whatever.
> </sidebar>

[KSB] Here are the systems that I work on whose POSIX shells build
character, in alphabetic order, with no attempt to single any out for
special recognition: AIX, Busybox (Linux), HP-UX, Solaris, Tru64 UNIX,
z/OS.

Regards
-- Bhaskar

-- 
Windows does to computers what smoking does to humans
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug