#9 scripts/findos.sh fails on Debian testing

Arthur Norman
build (2)
Carl Witty

I run Debian testing (the semi-bleeding-edge version of Debian); scripts/findos.sh gives an OS that makes scripts/findhost.sh fail:

reduce-algebra$ ./scripts/findos.sh
Debian GNU/Linux squeeze/sid \n \l
reduce-algebra$ ./scripts/findhost.sh `./config.guess`
sed: -e expression #1, char 18: unterminated `s' command
sed: -e expression #1, char 14: unterminated `s' command

reduce-algebra$ cat /etc/issue
Debian GNU/Linux squeeze/sid \n \l

reduce-algebra$ sh -x scripts/findos.sh
+ os=unknown
+ case `uname -a` in
++ uname -a
+ test -f /etc/issue
++ cat /etc/issue
+ issue='Debian GNU/Linux squeeze/sid \n \l'
++ echo 'Debian GNU/Linux squeeze/sid \n \l'
++ head -1
+ hissue='Debian GNU/Linux squeeze/sid \n \l'
+ test 'xDebian GNU/Linux squeeze/sid \n \l' = x
+ case $issue in
++ echo Debian GNU/Linux squeeze/sid '\n' '\l'
++ sed 's/^[^0-9]*\([0-9][0-9]*\.*[0-9]*\).*$/debian\1/'
+ os='Debian GNU/Linux squeeze/sid \n \l'
+ echo Debian GNU/Linux squeeze/sid '\n' '\l'
Debian GNU/Linux squeeze/sid \n \l
+ exit
reduce-algebra$ sh -x scripts/findhost.sh `./config.guess`
+ test x = x
+ test -x /opt/sfw/bin/gsed
+ test -x /usr/local/bin/gsed
+ test -x /usr/bin/gsed
+ SED=sed
+ a=scripts/findhost.sh
+ c=unknown
+ case $a in
+ case $a in
++ pwd
+ c=/home/cwitty/svn-reduce/reduce-algebra/scripts/findhost.sh
+ here=/home/cwitty/svn-reduce/reduce-algebra/scripts
+ host=i686-pc-linux-gnu
+ shift
++ /home/cwitty/svn-reduce/reduce-algebra/scripts/findos.sh
+ variant='Debian GNU/Linux squeeze/sid \n \l'
+ case $host in
+ test 'xDebian GNU/Linux squeeze/sid \n \l' '!=' xunknown
++ echo i686-pc-linux-gnu
++ sed -e s/-suse-/-pc-/
+ host=i686-pc-linux-gnu
++ echo i686-pc-linux-gnu
++ sed -e s/linux-gnu/Debian GNU/Linux squeeze/sid '\n' '\l/'
sed: -e expression #1, char 18: unterminated `s' command
+ host=
++ echo
++ sed -e s/apple/Debian GNU/Linux squeeze/sid '\n' '\l/'
sed: -e expression #1, char 14: unterminated `s' command
+ host=
+ debug=
+ m32=
+ m64=
+ original=
+ echo

+ exit 0


  • Arthur Norman
    Arthur Norman

    Fair cop! So this is a version of Debian that does not have a date or a release number in the first line of /etc/issue, but does have "/" characters there, and that messes up the code I have that tries to detect which OS variant you are on. You will understand that the code there will always be "delicate" and new OS variants that put unexpected stuff there will cause trouble, but it is there because different linux (etc) variants are not binary compatible. Do you feel like suggesting a fix to findos.sh that will make it robust against not just this one case of the testing Debian but against a decent family of other possible cases? My guess/hope is that sonebody who runs a bleeding-esge OS release may be better at making shell scripts carefully portable than I am!!!

  • Carl Witty
    Carl Witty

    Sorry, I have no insight on what /etc/issue might look like on a variety of systems. (I didn't even know what it looked like on my own system, until I started looking into this bug.)

    Maybe you want to look into using lsb_release instead? I'm not sure how widely it's available, but it looks useful. On my machine, "lsb_release -a" prints:

    Distributor ID: Debian
    Description: Debian GNU/Linux 5.0 (lenny)
    Release: 5.0
    Codename: lenny

    (other flags print subsets of this information).

  • Arthur Norman
    Arthur Norman

    I have tried to check in a new version of the findos.sh script that is intended
    (a) to use lsb_release if that exists
    (b) to filter out slashes and whitespace in system names to leave valid file-name components

    It is SUPPOSED to give the same identification for all existing systems, but should be more reliable if some system manager has updated /etc/issue or if the system-name is not of the form "vendor version.version" with numeric version identification.

    If you are still watching please try again on your testing Debian and tell me if I have got it good enough for you...

  • Rainer Schöpf
    Rainer Schöpf

    Believed fixed.

  • Rainer Schöpf
    Rainer Schöpf

    • labels: --> build
    • status: open --> closed
    • assigned_to: Arthur Norman
    • milestone: -->