Ask a Question related to Linux / Unix Administration, Design and Development.

  1. #1

    Default 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).
    >>>> 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


    familie oehler Guest

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. FreeBSD Bourne Shell
      Does anyone know where one can get the sh of FreeBSD?
    4. 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...
    5. 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
  3. #2

    Default Re: bourne-sh behavior

    In article <40e7a018$0$332$4d4ef98e@read.news.ch.uu.net>,
    "familie oehler" <oehlers@bluewin.ch> wrote:
    > 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.
    Remember, the word parsing algorithm is primarily intended for parsing
    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

  4. #3

    Default Re: bourne-sh behavior

    familie oehler wrote:

    [...]
    > 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
    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"):

    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

  5. #4

    Default Re: bourne-sh behavior



    familie oehler wrote:
    > 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
    >
    >
    Yes, bash and ksh do

    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

  6. #5

    Default 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

  7. #6

    Default Re: bourne-sh behavior

    * familie oehler <oehlers@bluewin.ch>:
    > 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 on OSF/1^WDEC UNIX^WCompaq Tru64 UNIX behaves the same way as
    Solaris' /bin/sh, e.g. "found only 6 token".

    You could use /usr/xpg4/bin/sh on Solaris.

    - Andi
    Andreas Karrer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139