Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 199356 - net-dialup/isdn4k-utils-3.11_pre20071003: syntax error in init-scripts
Summary: net-dialup/isdn4k-utils-3.11_pre20071003: syntax error in init-scripts
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Highest major (vote)
Assignee: Gentoo Dialup Developers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-16 12:47 UTC by Matthias Schwarzott
Modified: 2009-11-28 21:25 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Schwarzott gentoo-dev 2007-11-16 12:47:28 UTC
# rc
 * Caching service dependencies ...
/etc/init.d/hisax: line 31: syntax error near unexpected token `<'
/etc/init.d/hisax: line 31: `   if ! read _it _lin < <(/bin/head 2>/dev/null -n1 /dev/isdninfo); then'
/etc/init.d/isdn: line 16: syntax error near unexpected token `<'
/etc/init.d/isdn: line 16: `    read -a IDMAP < <(/bin/head 2>/dev/null -n1 /dev/isdninfo) || return 1'
/etc/init.d/isdnlog.contr0: line 13: syntax error near unexpected token `<'
/etc/init.d/isdnlog.contr0: line 13: `  read -a IDMAP < <(/bin/head 2>/dev/null -n1 /dev/isdninfo) || return 1 [ ok ]
Comment 1 Alin Năstac (RETIRED) gentoo-dev 2007-11-16 13:48:22 UTC
It works on my box. What version of bash you have?
Comment 2 Matthias Schwarzott gentoo-dev 2007-11-16 14:28:45 UTC
I use bash-3.2_p17-r1. Btw. the init-script also is bash-only - but well, I don't use it for now.

But I am sure this is never valid code:
/etc/init.d/isdn line 16:
# read -a IDMAP < <(/bin/head 2>/dev/null -n1 /dev/isdninfo) || return 1

That additional "<" is strange.
Comment 3 Matthias Schwarzott gentoo-dev 2007-11-16 14:31:50 UTC
To give more info.
I also use baselayout-2.

# emerge --info
Portage 2.1.3.19 (default-linux/x86/2007.0/desktop, gcc-4.2.2, glibc-2.7-r0, 2.6.22-suspend2-r2 i686)
=================================================================
System uname: 2.6.22-suspend2-r2 i686 AMD Athlon(tm) XP 3000+
Timestamp of tree: Unknown
distcc 2.18.3 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.4 [enabled]
app-shells/bash:     3.2_p17-r1
dev-java/java-config: 1.3.7, 2.1.2-r1
dev-lang/python:     2.3.6-r3, 2.4.4-r6, 2.5.1-r3
dev-python/pycrypto: 2.0.1-r6
dev-util/ccache:     2.4-r7
sys-apps/baselayout: 2.0.0_rc6
sys-apps/sandbox:    1.2.18.1-r2
sys-devel/autoconf:  2.13, 2.61-r1
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10
sys-devel/binutils:  2.18-r1
sys-devel/gcc-config: 1.4.0-r4
sys-devel/libtool:   1.5.24
virtual/os-headers:  2.6.23-r1
ACCEPT_KEYWORDS="x86 ~x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=pentium3 -mtune=athlon-xp -fomit-frame-pointer -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config"
CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/eselect/compiler /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/splash /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"
CXXFLAGS="-O2 -march=pentium3 -mtune=athlon-xp -fomit-frame-pointer -pipe"
DISTDIR="/usr/my-distfiles"
FEATURES="autoaddcvs ccache collision-detect cvs distlocks metadata-transfer parallel-fetch sandbox sfperms sign splitdebug strict unmerge-orphans userfetch"
GENTOO_MIRRORS="ftp://ftp.mneisen.org/gentoo http://gentoo.mneisen.org/"
LANG="de_DE.utf8"
LC_ALL="de_DE.utf8"
LDFLAGS="-Wl,-O1,--as-needed"
LINGUAS="de en en_GB"
PKGDIR="/usr/my-packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/overlays/zzam /usr/local/overlays/vdr/experimental /usr/local/overlays/vdr/vdr-1.5 /usr/local/overlays/vdr/testing /usr/local/overlays/layman/sunrise /usr/local/overlays/layman/musicbrainz /usr/local/overlays/gentoo.de /usr/local/overlays/dev-overlay"
SYNC="cvs://zzam@cvs.gentoo.org:/var/cvsroot"
USE="3dnow 3dnowext X Xaw3d a52 aac acl acpi alsa amr apache2 artswrappersuid audacious berkdb bitmap-fonts bluetooth bzip2 cairo cap caps cdaudio cddb cdparanoia cdr cli cracklib crypt cups curl dbus doc dri dts dvb dvd dvdr dvdread eds emboss encode evo exif fam fbcon ffmpeg firefox font-server fortran fuse gcj gdbm gif gimpprint glut gnutls gphoto2 gpm graphviz gstreamer gtk gtk2 hal hbci iconv imap ipv6 isdnlog java jpeg jpeg2k kde kdexdeltas kerberos libdvdread lirc logitech-mouse mad midi mikmod mjpeg mmx mmxext mng mp3 mpeg mplayer mudflap musicbrainz mysql ncurses nls nptl nptlonly nsplugin nvram offensive ogg opengl openmp oss pam pcre pdf perl php png ppds pppd projectx python qt3 qt3support qt4 quotes readline reflection regex samba session sms sndfile spell spl sql sqlite sse ssl svg taglib tcltk tcpd theora threads tiff truetype truetype-fonts type1-fonts unicode usb userlocales vcd vdr visualization vorbis webdav win32codecs wma wmf x264 x86 xcomposite xinerama xml xorg xrandr xslt xv xvid zlib zvbi" ALSA_CARDS="emu10k1 intel8x0" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" CAMERAS="ptp2" DVB_CARDS="ttpci usb-wt220u dibusb-usb2 usb-dib0700" ELIBC="glibc" INPUT_DEVICES="mouse keyboard" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text xosd" LINGUAS="de en en_GB" LIRC_DEVICES="all" USERLAND="GNU" VIDEO_CARDS="nvidia v4l vesa vbdev nv"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 4 Alin Năstac (RETIRED) gentoo-dev 2007-11-16 15:03:12 UTC
I'm not a bash guru, but this command works for me:
  mrness@a-nastac ~ $ read -a IDMAP < <(/bin/head 2>/dev/null -n1 /proc/cpuinfo)
  mrness@a-nastac ~ $ echo $IDMAP
  processor

If I remove the first <, the read command wait from stdin.
Comment 5 Alin Năstac (RETIRED) gentoo-dev 2007-11-16 15:19:58 UTC
Okay, I discovered what <(foo) does:
  mrness@a-nastac ~ $ echo <(/bin/head 2>/dev/null -n1 /proc/cpuinfo)
  /dev/fd/63
As you can see, bash runs the command with a unnamed pipe as its stdout.

My bash version is bash-3.2_p17.
Comment 6 Stefan Briesenick (RETIRED) gentoo-dev 2007-11-17 18:40:15 UTC
well, the <() syntax is /bin/bash only. In /bin/sh mode, bash doesn't accept this special syntax to be compatible with other POSIX-shells. Old baselayout used /bin/bash, new baselayout uses /bin/sh. 

It should be changed to pipes only to fix this issue. But take care, if exit-codes are used, these should be converted from ${?} to ${PIPESTATUS[0]} then.
Comment 7 Stefan Briesenick (RETIRED) gentoo-dev 2007-11-17 18:55:51 UTC
@zzam:

this is very special and may be a little bit tricky to convert to POSIX:

  read -a IDMAP < <(/bin/head 2>/dev/null -n1 /dev/isdninfo) || return 1

it works like this:

"<(/bin/head 2>/dev/null -n1 /dev/isdninfo)" is expanded to something like /dev/fd/XY. 'head' is executed in a subshell, stdout of this subshell is available via /dev/fd/XY.

"read -a IDMAP" reads this output via stdin (hence the '<').

if 'read' gets an error (exit-code != 0), it will "return 1".

the sexyness of the bash-style is following:

1. you get the returncode of 'read' directly into $?
2. just 'head' is executed in a subshell, not 'read'.

the command above can be translated into something like this (but read further to understand, why this doesn't work in this case!):

head 2>/dev/null -n1 /dev/isdninfo | read -a IDMAP
[ ${PIPESTATUS[1]} -ne 0 ] && return 1

since we need the result of 'read', we need to address ${PIPESTATUS[1]}, *not* just ${?} to be sure we have the right exit-code.

but be aware: 'read' is executed in a subshell and the variable 'IDMAP' isn't available then in the parent-shell. Very odd! The problem is, that you have to use 'read' within the parent-shell (i.e. *no* subshell) to get the variable filled.

That was the reason, I initially used the bash-style syntax, because it was the perfect solution for the subshell problem.

Any ideas?
Comment 8 Alin Năstac (RETIRED) gentoo-dev 2008-01-03 12:29:28 UTC
Well, can we finally fix this bug and close it? | would like to see this version stabilized so I could close bug 160186.
Comment 9 Jakub Moc (RETIRED) gentoo-dev 2008-01-23 19:51:07 UTC
(In reply to comment #8)
> Well, can we finally fix this bug and close it? | would like to see this
> version stabilized so I could close bug 160186.

This POSIX nonsense is absolutely no regression and baselayout-2 is package.masked. Please stabilize something that at least compiles because current stable does not due to severely broken autotools handling.
Comment 10 Diego Elio Pettenò (RETIRED) gentoo-dev 2009-07-30 17:55:37 UTC
One year and a half later we're still at the same point, I'm going to consider masking isdn4k-utils and removing it for QA failure seen the multiple bugs related to that.
Comment 11 Torsten Veller (RETIRED) gentoo-dev 2009-11-28 21:25:26 UTC
Removed from the tree.