On Fri, Apr 08, 2016 at 08:51:52AM +1000, Cameron Simpson wrote:
> On 07Apr2016 10:37, derek martin <[email protected]> wrote:
> >I've yet to notice any of the so-called benefits of getting older,
> >that people sometimes extoll...
> 
> My father once asserted that it was better than the alternative.

Fair point!  On rare occasions though, I'm not so sure...

> Oh, please digress!
> 
> I tend to use printf over echo for when I want well controlled
> output; the BSD/SysV echo stuff has been a pain point for decades so
> I try to just avoid it when I'm outputting an "unknown" string. 

I've only taken to using printf lately in shell scripts, mostly for
the likes of:

  i=0; while [ $i -lt $limit ]; do
    filename=`printf "file%04d" $i`
    # do something with file0xxx
    ...

> What other scripting shortcomings have you encountered with dash? I
> haven't used it much myself, but would hope to have my scripts
> portable enough to work with it.

Honestly I can't recall...  It's been a few years since I used shell
scripts for much more than stringing together a bunch of other
programs I've written or short one-offs.  One thing is I have a
handful of scripts I use a lot that make use of bash arrays to convert
numeric input into strings to be used in SQL queries.  Bash is hardly
the only shell that provides arrays... I want them in shells I use for
scripting, and frankly I want to use /bin/sh (or at least a shell that
behaves exactly like I expect /bin/sh to behave)...

I specifically DO NOT want to use /bin/bash in my shell scripts,
because this changes various behaviors of the shell, including causing
it to read certain of your shell startup files when your script starts
(yes, even in non-interactive shells), which is not what you want if
you're running shell scripts.

Honestly, what I really want is for the distros to return bash to
/bin/sh, configure the kernel and any relevant startup scripts to use
dash directly if that's what they want to use to start the system up,
and maybe consider statically linking /bin/bash so that it doesn't
break if shared libs are missing (which it may already be, I'm too
lazy to open a window to check).  =8^)

On Thu, Apr 07, 2016 at 04:23:18PM -0700, David Champion wrote:
> Speaking of which, it's taken me until the last year to use $(command)
> consistently instead of `command`, and I'm not sure anymore why I was
> a stickler.  I assume some older shell didn't support $() but I can't
> recall which.

I still don't, as you may have noticed above. ;-)  But I DO use it,
and notably you can combine `` and $() to get two levels of execution.
That's occasionally handy.

-- 
Derek D. Martin    http://www.pizzashack.org/   GPG Key ID: 0xDFBEAD02
-=-=-=-=-
This message is posted from an invalid address.  Replying to it will result in
undeliverable mail due to spam prevention.  Sorry for the inconvenience.

Attachment: pgpyURJxa9152.pgp
Description: PGP signature

Reply via email to