FW: Process substitution into loop

James Hunt james.hunt at canonical.com
Tue Jun 14 10:11:53 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14/06/11 00:56, Grail Dane wrote:
> Hi James
> 
> Thanks very much for the reply.  As you can probably guess the typo is in the email but not in
> the actual script.  I did further testing and as per the bash install instructions:
> 
> *sh*
> 
> 	
> 
> A symlink to the *bash* program; when invoked as *sh*, *bash* tries to mimic the startup behavior of
> historical versions of *sh* as closely as possible, while conforming to the POSIX standard as well
> 
> 
> 
> This would indicate that it is a bash builtin feature to use only POSIX compliant options.
> So from the Cookbook you may need to edit the following from the section you pointed me to:
> 
> If you wish to change this, you can either make /bin/sh a symbolic link to your chosen shell
Updated:

http://upstart.ubuntu.com/cookbook/#changing-the-default-shell

Regards,

James.

> 
> As this does not work as expected in this case and it may be similar for other shells to.
> 
> I will try the workaround of adding it as the default shell in the build and let you know how it goes :)
> 
> Cheers
> grail
> 
>> Date: Fri, 10 Jun 2011 11:22:12 +0100
>> From: james.hunt at ubuntu.com
>> To: grail69 at hotmail.com
>> CC: upstart-devel at lists.ubuntu.com
>> Subject: Re: Process substitution into loop
>>
>> Hi Grail,
>>
>> On 10/06/11 05:46, Grail Dane wrote:
>> >
>> >
>> >> Date: Thu, 9 Jun 2011 21:05:45 -0700
>> >> From: steve.langasek at ubuntu.com
>> >> To: grail69 at hotmail.com
>> >> CC: upstart-devel at lists.ubuntu.com
>> >> Subject: Re: Process substitution into loop
>> >>
>> >> On Fri, Jun 10, 2011 at 03:53:15AM +0000, Grail Dane wrote:
>> >> > Just wondering, as I can't find by googling, if it is at all possible to
>> >> > do a processsubstitution into a while loop within an upstart script?
>> >>
>> >> > Example:
>> >> > while read -r DEVICE
>> >> > do
>> >> > ip link set dev $DEVICE up
>> >> > done< <(ip link | awk '/^[0-9]/ && !/UP/ && gsub(/:/,""){print $2})
>> You have an error in your script: it is missing the closing tick (see below).
>>
>> >>
>> >> > When issuing the start command on the script I get:
>> >> > /proc/self/fd/10: line 6: syntax error near unexpected '<'init:
>> >> > network-interfaces main process (1367) terminated with status 2start: Job
>> >> > failed to start Would appreciated if someone would identify if i have done
>> >> > something wrong or if this not a supported feature?
>> >>
>> >> The <() syntax is not part of the POSIX standard, it's a bash extension.
>> >> Upstart uses /bin/sh to interpret scripts, as is customary; chances are
>> >> you're running on a system where /bin/sh is not bash, and as a result this
>> >
>> > Actually /bin/sh is a symbolic link to bash on my system. Is there anyway to have bash as the
>> > shell used?
>>
>> script
>> /bin/bash <<EOT
>> while read -r DEVICE
>> do
>> echo "DEBUG: ip link set dev $DEVICE up" > /tmp/grail.log
>> done < <(ip link | awk '/^[0-9]/ && !/UP/ && gsub(/:/,""){print $2}')
>> EOT
>> end script
>>
>> Also, just for you :)...
>>
>> http://upstart.ubuntu.com/cookbook/#changing-the-default-shell
>>
>> Regards,
>>
>> James.
>>
>> >
>> >> syntax is not supported.
>> >>
>> >> A supported syntax would be:
>> >>
>> >> ip link | awk '/^[0-9]/ && !/UP/ && gsub(/:/,""){print $2}' |
>> >> while read -r DEVICE
>> >> do
>> >> ip link set dev $DEVICE up
>> >> done
>> >>
>> >> --
>> >> Steve Langasek Give me a lever long enough and a Free OS
>> >> Debian Developer to set it on, and I can move the world.
>> >> Ubuntu Developer http://www.debian.org/
>> >> slangasek at ubuntu.com vorlon at debian.org
>> >
>>
> 


- -- 
Cheers,

James.
- --
James Hunt
____________________________________
Ubuntu Foundations Team, Canonical.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk33M+YACgkQYBWEaHcQG9ftywCdHIULB3wo23cekhh4fMw9HyYz
sr4An0WuLdDbQZnUjBJPDkX20CbxgKik
=yNSk
-----END PGP SIGNATURE-----



More information about the upstart-devel mailing list