Ask a Question related to Linux / Unix Administration, Design and Development.
-
familie oehler #1
bourne-sh behavior
hi
i was programing installation procedures based on bourne-sh, sed, awk and all
other nice staff.
but than i run into troubles with the bourne-sh.
i found out the jsh (bourne-sh in solaris) is parsing strings in a rather
funny way. i contacted sun and the answer was - that's the way bourne sh is
working since ever. i hardly can believe this.
i tried my old 286 with interactive unix (1989) - but it does not work any
more. the ega monitor is missing. i so try to figure out the behavior of the
real bourne-sh by contacting other unix poeple.
the problem is simple: empty tokens are ignored. no other parsing algorythm in
any library or tool like awk, sed ... behave that way. anyone who has
experience in parsing information knows - it does not make sense because your
loosing orientation.
i created a verry simple script testing the problem and showing the testsuite.
if you are running any at&t or bsd ?nix like SunOS (not solaris), unixware, sgi
or even svr4 implementation on amdahl, please copy the following script and
send the output to [email]oehlers@bluewin.ch[/email]. please make sure /bin/sh is a bourne-sh
(linux is bash and not bourne).
#!/bin/sh>>>> test.sh
LIST="a:b:c:::d:e:f"
IFS=':'
set $LIST
echo "======= part system information ================
uname -a
ps
file /bin/sh
echo "======= part system information ================
if [ $# -lt 8 ] ; then
echo "NOK==> found only $# token"
else
echo "OK==> found all 8 token"
fi
<<<< test.sh
thanks for help
george oehler
familie oehler Guest
-
Behavior help
I have a 6 button interface that plays different movies with each button. Is there a behavior script I can write to play frames 188 - 194 and then... -
Odd name behavior in OS X
I am running OS X on a new PowerBook, and I have some strange behavior that I need advice on. When I "Get Info" on a file from the Finder, and I... -
FreeBSD Bourne Shell
Does anyone know where one can get the sh of FreeBSD? -
very odd behavior of X11 GUI
Hi, I have a X11 interface which runs well on Solaris 2.6, even on Solaris 7 (did not try 8). But on Solaris 9 it does not run because of an... -
Looking for a behavior
Is there a behavior where you clickOn or mouseOver an image and a table row can be high-lighted with a different color? Thank you -
Barry Margolin #2
Re: bourne-sh behavior
In article <40e7a018$0$332$4d4ef98e@read.news.ch.uu.net>,
"familie oehler" <oehlers@bluewin.ch> wrote:
Remember, the word parsing algorithm is primarily intended for parsing> hi
>
> i was programing installation procedures based on bourne-sh, sed, awk and all
> other nice staff.
>
> but than i run into troubles with the bourne-sh.
>
> i found out the jsh (bourne-sh in solaris) is parsing strings in a rather
> funny way. i contacted sun and the answer was - that's the way bourne sh is
> working since ever. i hardly can believe this.
>
> i tried my old 286 with interactive unix (1989) - but it does not work any
> more. the ega monitor is missing. i so try to figure out the behavior of the
> real bourne-sh by contacting other unix poeple.
>
> the problem is simple: empty tokens are ignored. no other parsing algorythm
> in
> any library or tool like awk, sed ... behave that way. anyone who has
> experience in parsing information knows - it does not make sense because your
> loosing orientation.
command lines, which use whitespace as the delimiter. If you typed:
cat foo bar
would you really expect it to operate differently from
cat foo bar
? Do you expect it to look for a file named "" because there's an
"empty token" between the two spaces?
If you want a tool that doesn't treat a sequence of delimiters as a
single delimiter, try "cut".
--
Barry Margolin, [email]barmar@alum.mit.edu[/email]
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Barry Margolin Guest
-
Heiner Steven #3
Re: bourne-sh behavior
familie oehler wrote:
[...]Your script parses LIST to 8 tokens with the following> the problem is simple: empty tokens are ignored. no other parsing algorythm in
> any library or tool like awk, sed ... behave that way. anyone who has
> experience in parsing information knows - it does not make sense because your
> loosing orientation.
>
> i created a verry simple script testing the problem and showing the testsuite.
> if you are running any at&t or bsd ?nix like SunOS (not solaris), unixware, sgi
> or even svr4 implementation on amdahl, please copy the following script and
> send the output to [email]oehlers@bluewin.ch[/email]. please make sure /bin/sh is a bourne-sh
> (linux is bash and not bourne).
>>>>>>>test.sh
> #!/bin/sh
> LIST="a:b:c:::d:e:f"
> IFS=':'
> set $LIST
> echo "======= part system information ================
> uname -a
> ps
> file /bin/sh
> echo "======= part system information ================
> if [ $# -lt 8 ] ; then
> echo "NOK==> found only $# token"
> else
> echo "OK==> found all 8 token"
> fi
> <<<< test.sh
shells (Linux):
ash ASH
bash BASH 2.05b.0(1)-release
pdksh KSH @(#)PD KSH v5.2.14 99/07/13.2
ksh93 KSH93 Version M 1993-12-28 m
"zsh" didn't parse the list at all, but set one single argument
("a:b:c:::d:e:f"):
zsh ZSH 4.1.1
Heiner
--
___ _
/ __| |_ _____ _____ _ _ Heiner STEVEN <heiner.steven@nexgo.de>
\__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit
|___/\__\___|\_/\___|_||_| [url]http://www.shelldorado.com/[/url]
Heiner Steven Guest
-
Michael Tosch #4
Re: bourne-sh behavior
familie oehler wrote:Yes, bash and ksh do> hi
>
> i was programing installation procedures based on bourne-sh, sed, awk and all
> other nice staff.
>
> but than i run into troubles with the bourne-sh.
>
> i found out the jsh (bourne-sh in solaris) is parsing strings in a rather
> funny way. i contacted sun and the answer was - that's the way bourne sh is
> working since ever. i hardly can believe this.
>
> i tried my old 286 with interactive unix (1989) - but it does not work any
> more. the ega monitor is missing. i so try to figure out the behavior of the
> real bourne-sh by contacting other unix poeple.
>
> the problem is simple: empty tokens are ignored. no other parsing algorythm in
> any library or tool like awk, sed ... behave that way. anyone who has
> experience in parsing information knows - it does not make sense because your
> loosing orientation.
>
> i created a verry simple script testing the problem and showing the testsuite.
> if you are running any at&t or bsd ?nix like SunOS (not solaris), unixware, sgi
> or even svr4 implementation on amdahl, please copy the following script and
> send the output to [email]oehlers@bluewin.ch[/email]. please make sure /bin/sh is a bourne-sh
> (linux is bash and not bourne).
>
>>>>>>>test.sh
> #!/bin/sh
> LIST="a:b:c:::d:e:f"
> IFS=':'
> set $LIST
> echo "======= part system information ================
> uname -a
> ps
> file /bin/sh
> echo "======= part system information ================
> if [ $# -lt 8 ] ; then
> echo "NOK==> found only $# token"
> else
> echo "OK==> found all 8 token"
> fi
> <<<< test.sh
>
> thanks for help
>
> george oehler
>
>
bash-2.03$ LIST="a:b:c:::d:e:f"
bash-2.03$ IFS=':'
bash-2.03$ set $LIST
bash-2.03$ echo $#
8
bash-2.03$ LIST="a b c d e f"
bash-2.03$ IFS=' '
bash-2.03$ set $LIST
bash-2.03$ echo $#
6
i.e. treat white-space and non-white-space delimiters differently.
While Bourne shell does not differentiate.
Michael Tosch Guest
-
Stephane CHAZELAS #5
Re: bourne-sh behavior
2004-07-04, 18:38(+02), Heiner Steven:
[...][...]>> LIST="a:b:c:::d:e:f"
>> IFS=':'
>> set $LIST[...]> Your script parses LIST to 8 tokens with the following
> shells (Linux):
>
> ash ASH
> bash BASH 2.05b.0(1)-release
> pdksh KSH @(#)PD KSH v5.2.14 99/07/13.2
> ksh93 KSH93 Version M 1993-12-28 m
>
> "zsh" didn't parse the list at all, but set one single argument
> ("a:b:c:::d:e:f"):
Yes, that's a feature of zsh, while other shells could be
regarded bogus in that concern. In zsh, you have to explicitely
require word splitting (and also filename generation)
set -- $=LIST
and to also have filename generation:
set -- $=~LIST
(zsh also has a sh compatible mode in which splitting and
globbing is done implicitely, see also the SH_WORD_SPLIT and
GLOB_SUBST options).
See question 3.1 of zsh faq
[url]http://www.faqs.org/faqs/unix-faq/shell/zsh/[/url]
[url]http://zsh.sourceforge.net/FAQ/zshfaq03.html#l17[/url]
--
Stephane
Stephane CHAZELAS Guest
-
Andreas Karrer #6
Re: bourne-sh behavior
* familie oehler <oehlers@bluewin.ch>:
/bin/sh on OSF/1^WDEC UNIX^WCompaq Tru64 UNIX behaves the same way as> or even svr4 implementation on amdahl, please copy the following script and
> send the output to [email]oehlers@bluewin.ch[/email]. please make sure /bin/sh is a bourne-sh
> (linux is bash and not bourne).
Solaris' /bin/sh, e.g. "found only 6 token".
You could use /usr/xpg4/bin/sh on Solaris.
- Andi
Andreas Karrer Guest



Reply With Quote

