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

Re: Bashism (Was: Locale testing)



On Sat, Dec 06, 2008 at 11:42:38PM +0200, Dotan Cohen wrote:
> 2008/12/6 Tzafrir Cohen <tzafrir@cohens.org.il>:
> > This is bashism.
> >
> 
> That is why we call it "bash"!
> 
> > #!/bin/sh
> > LC_ALL="" LC_TIME="en_DK.utf8" /usr/bin/thunderbird "$@"
> >
> > Or even better:
> >
> > #!/bin/sh
> > LC_ALL="" LC_TIME="en_DK.utf8" exec /usr/bin/thunderbird "$@"
> >
> 
> I could probably google and find out why the semicolons are not
> necessary, 

  VAR="value" command

will run 'command' with the variable VAR set to "value".

This is why you get a strange error with the following:

  VAR=value with spaces

It will complain about trying to run the command 'with spaces' (or 
rather: command 'with' with parameter 'spaces').

> nor the export command, but why is the "exec" preferable?

exec (like all the exec* system calls) replace the current process.

Try an 'strace -f' following script:

  #!/bin/sh
  exec /bin/true

which will show you that no forking was done, vs:

  #!/bin/sh
  /bin/true

Which runs /bin/true in a sub process, waits for it to exit and only 
then exist.

-- 
Tzafrir Cohen         | tzafrir@jabber.org | VIM is
http://tzafrir.org.il |                    | a Mutt's
tzafrir@cohens.org.il |                    |  best
ICQ# 16849754         |                    | friend


Reply to: