FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 12-06-2008, 08:42 PM
"Dotan Cohen"
 
Default Bashism (Was: Locale testing)

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, nor the export command, but why is the "exec" preferable?

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-*-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-*-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه*-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-*-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-*-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
 
Old 12-06-2008, 08:52 PM
Tzafrir Cohen
 
Default 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


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 12-06-2008, 08:59 PM
Ken Irving
 
Default 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, nor the export command, but why is the "exec" preferable?

Probably just because it doesn't leave the wrapper script as a
process to be returned to after you're done with thunderbird.

Ken

--
Ken Irving


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 12-06-2008, 09:08 PM
"Boyd Stephen Smith Jr."
 
Default Bashism (Was: Locale testing)

On Saturday 06 December 2008, "Dotan Cohen" <dotancohen@gmail.com> wrote
about 'Bashism (Was: Locale testing)':
>I could probably google and find out why the semicolons are not
>necessary, nor the export command, but why is the "exec" preferable?

That way the thunderbird process replaces the shell process rather than the
shell process simply waiting around for the thunderbird process to die and
then dieing itself.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss03@volumehost.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.org/ \_/
 
Old 12-06-2008, 09:33 PM
"Dotan Cohen"
 
Default Bashism (Was: Locale testing)

2008/12/6 Tzafrir Cohen <tzafrir@cohens.org.il>:
> 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.
>

+5 Informative, thanks!

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-*-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-*-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه*-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-*-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-*-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
 
Old 12-06-2008, 10:25 PM
"Boyd Stephen Smith Jr."
 
Default bashism (was: Locale testing)

On Saturday 06 December 2008, Tzafrir Cohen <tzafrir@cohens.org.il> wrote
about 'Re: Locale testing':
>Off-topic:
>
>On Sat, Dec 06, 2008 at 10:06:36PM +0200, Dotan Cohen wrote:
>> #!/bin/bash
>> export LC_ALL="";export LC_TIME="en_DK.utf8";/usr/bin/thunderbird "$@"
>
>This is bashism.

Yes.

>#!/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 "$@"

Well, that's changing more than the bash-ism.

The bashism here is:
export VAR=<value>

For maximum compatibility, that needs to be:
VAR=<value>; export VAR

Standard "export" doesn't handle setting the value of the variable, it
*only* marks the variable as exported.
--
Boyd Stephen Smith Jr. ,= ,-_-. =.
bss03@volumehost.net ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.org/ \_/
 
Old 12-06-2008, 10:47 PM
"Dotan Cohen"
 
Default bashism (was: Locale testing)

2008/12/7 Boyd Stephen Smith Jr. <bss03@volumehost.net>:
> For maximum compatibility, that needs to be:
> VAR=<value>; export VAR
>

Compatibility with what?

--
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il

א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-*-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת
ا-ب-ت-ث-ج-*-خ-د-ذ-ر-ز-س-ش-ص-ض-ط-ظ-ع-غ-ف-ق-ك-ل-م-ن-ه*-و-ي
А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-*-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-*-Ю-Я
а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я
ä-ö-ü-ß-Ä-Ö-Ü
 
Old 12-06-2008, 11:21 PM
"Kelly Clowers"
 
Default bashism (was: Locale testing)

On Sat, Dec 6, 2008 at 15:47, Dotan Cohen <dotancohen@gmail.com> wrote:
> 2008/12/7 Boyd Stephen Smith Jr. <bss03@volumehost.net>:
>> For maximum compatibility, that needs to be:
>> VAR=<value>; export VAR
>>
>
> Compatibility with what?

sh, ash, dash, zsh, pdksh, etc.


Cheers,
Kelly Clowers


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 12-07-2008, 12:04 AM
"Boyd Stephen Smith Jr."
 
Default bashism (was: Locale testing)

On Saturday 2008 December 06 17:47, Dotan Cohen wrote:
> 2008/12/7 Boyd Stephen Smith Jr. <bss03@volumehost.net>:
> > For maximum compatibility, that needs to be:
> > VAR=<value>; export VAR
>
> Compatibility with what?

UNIX. The Single Unix Specification is maintained by the Open Group who
certify UNIX products.

In particular, Mac OS X is certified UNIX.
--
Boyd Stephen Smith Jr. * * * * * * * * * * ,= ,-_-. =.
bss03@volumehost.net * * * * * * * * * * *((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy * * * * * `-'(. .)`-'
http://iguanasuicide.org/ * * * * * * * * * * *\_/ * *
 
Old 12-07-2008, 09:42 AM
Tzafrir Cohen
 
Default bashism (was: Locale testing)

On Sun, Dec 07, 2008 at 01:47:29AM +0200, Dotan Cohen wrote:
> 2008/12/7 Boyd Stephen Smith Jr. <bss03@volumehost.net>:
> > For maximum compatibility, that needs to be:
> > VAR=<value>; export VAR
> >
>
> Compatibility with what?

With older posix, I believe.

http://www.opengroup.org/onlinepubs/009695399/utilities/export.html

posh has no problem with that. checkbashism doesn't complain about it
(even with -p). Likewise zsh and busybox ash.

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


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 

Thread Tools




All times are GMT. The time now is 12:20 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org