bashisms (was: Re: New Geotag extension)



While it is likely that people will be using bash or zsh as their
interactive shell, I'm going to take the chance to be pedantic here. ;)
After all, this code might end up in a script with /bin/sh at the top.

On Wed, 2008-02-20 at 08:57 +0100, Roland Mas wrote:
>   I never remember understood why the Canon models have three
> different names depending on where the cameras are sold... but if
> Digital Rebel == EOS 350D, then you may find the following snippet
> useful:
> 
> (echo get-config time ; echo set-config time=$(date +%s)) \ 
>     | gphoto2 --shell &> /dev/null
                        ^^
This will only work with bash... if this shell snippet is run under
other POSIX shells, it might not work as expected. The portable way is
to replace &>/dev/null with >/dev/null 2>&1

In Ubuntu versions since Edgy and probably in the next Debian
release, /bin/sh points to dash (a small POSIX shell) rather than bash.
This kind of bashism is going to cause subtle bugs at some point,
unreproducible if another person is still using bash as /bin/sh.

There's only one script with bashisms in f-spot that I know about at the
moment:
http://bugzilla.gnome.org/516585

(The $() construct won't work under Solaris's default /bin/sh, but it is
specified by POSIX and much neater than backticks, so probably not worth
worrying about.)

-- 
Tim Retout <tim retout co uk>



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