Re: Shell script termination with exit function in backquotes

2011-03-22 Thread RW
On Sat, 19 Mar 2011 09:44:57 -0700 Devin Teske dte...@vicor.com wrote: At least two variations to the rule that { ... } is a block of commands executed in the current shell are: 1. When the block appears as a function Is that correct? I'd assumed that functions do execute in the current

Re: Shell script termination with exit function in backquotes

2011-03-22 Thread Jilles Tjoelker
Maxim Khitrov wrote: [$(exit) exits the main shell environment] This is a bug which is fixed in 9-current. Another message: On Sat, Mar 19, 2011 at 12:44 PM, Devin Teske dteske at vicor.com wrote: [all elements of multi-command pipelines are executed in a subshell] You're learning that

Re: Shell script termination with exit function in backquotes

2011-03-22 Thread Devin Teske
On Tue, 2011-03-22 at 12:32 +, RW wrote: On Sat, 19 Mar 2011 09:44:57 -0700 Devin Teske dte...@vicor.com wrote: At least two variations to the rule that { ... } is a block of commands executed in the current shell are: 1. When the block appears as a function Is that

Re: Shell script termination with exit function in backquotes

2011-03-20 Thread Ian Smith
in freebsd-questions Digest, Vol 354, Issue 10, Message: 4 On Sat, 19 Mar 2011 12:15:26 -0400 Maxim Khitrov m...@mxcrypt.com wrote: Here's another, but related, problem that I just ran into. The man page reads: Commands may be grouped by writing either (list) or

Re: Shell script termination with exit function in backquotes

2011-03-19 Thread Maxim Khitrov
On Mon, Mar 14, 2011 at 6:40 PM, Andres Perera andre...@zoho.com wrote: On Mon, Mar 14, 2011 at 7:46 AM, Maxim Khitrov m...@mxcrypt.com wrote: On Mon, Mar 14, 2011 at 3:16 AM, Andres Perera andre...@zoho.com wrote: On Sun, Mar 13, 2011 at 9:49 PM, Devin Teske dte...@vicor.com wrote: If you

Re: Shell script termination with exit function in backquotes

2011-03-19 Thread Devin Teske
On Mar 19, 2011, at 9:15 AM, Maxim Khitrov wrote: On Mon, Mar 14, 2011 at 6:40 PM, Andres Perera andre...@zoho.com wrote: On Mon, Mar 14, 2011 at 7:46 AM, Maxim Khitrov m...@mxcrypt.com wrote: On Mon, Mar 14, 2011 at 3:16 AM, Andres Perera andre...@zoho.com wrote: On Sun, Mar 13, 2011 at

Re: Shell script termination with exit function in backquotes

2011-03-19 Thread Maxim Khitrov
On Sat, Mar 19, 2011 at 12:44 PM, Devin Teske dte...@vicor.com wrote: On Mar 19, 2011, at 9:15 AM, Maxim Khitrov wrote: On Mon, Mar 14, 2011 at 6:40 PM, Andres Perera andre...@zoho.com wrote: On Mon, Mar 14, 2011 at 7:46 AM, Maxim Khitrov m...@mxcrypt.com wrote: On Mon, Mar 14, 2011 at 3:16

Re: Shell script termination with exit function in backquotes

2011-03-19 Thread perryh
Maxim Khitrov m...@mxcrypt.com wrote: ... these deviations should be noted in the man page to help eliminate such surprises. A single sentence would have sufficed in this case. As always, I'm sure patches would be welcome :) ___

Re: Shell script termination with exit function in backquotes

2011-03-19 Thread Andres Perera
On Sat, Mar 19, 2011 at 11:45 AM, Maxim Khitrov m...@mxcrypt.com wrote: Here's another, but related, problem that I just ran into. The man page reads:     Commands may be grouped by writing either           (list)     or           { list; }     The first form executes the commands in a

Re: Shell script termination with exit function in backquotes

2011-03-14 Thread Andres Perera
ash tries to overoptimize by running certain command substitutions without a subshell On Sun, Mar 13, 2011 at 7:56 PM, Maxim Khitrov m...@mxcrypt.com wrote: Hello everyone, I might be doing something dumb here, but this doesn't make sense to me. When I run the following script, I would expect

Re: Shell script termination with exit function in backquotes

2011-03-14 Thread Andres Perera
On Sun, Mar 13, 2011 at 9:49 PM, Devin Teske dte...@vicor.com wrote: If you make the changes that I've suggested, you'll have consistent execution. The reason you're having inconsistent behavior is because Linux has /bin/sh symbolically linked to /bin/bash while FreeBSD has a more

Re: Shell script termination with exit function in backquotes

2011-03-14 Thread Maxim Khitrov
On Mon, Mar 14, 2011 at 3:16 AM, Andres Perera andre...@zoho.com wrote: On Sun, Mar 13, 2011 at 9:49 PM, Devin Teske dte...@vicor.com wrote: If you make the changes that I've suggested, you'll have consistent execution. The reason you're having inconsistent behavior is because Linux has

Re: Shell script termination with exit function in backquotes

2011-03-14 Thread Andres Perera
On Mon, Mar 14, 2011 at 7:46 AM, Maxim Khitrov m...@mxcrypt.com wrote: On Mon, Mar 14, 2011 at 3:16 AM, Andres Perera andre...@zoho.com wrote: On Sun, Mar 13, 2011 at 9:49 PM, Devin Teske dte...@vicor.com wrote: If you make the changes that I've suggested, you'll have consistent execution.

Shell script termination with exit function in backquotes

2011-03-13 Thread Maxim Khitrov
Hello everyone, I might be doing something dumb here, but this doesn't make sense to me. When I run the following script, I would expect to see no output: #!/bin/sh exit_prog() { echo -n 'before' exit 0 echo -n 'after' } echo line 1: `exit_prog` echo line 2: echo

Re: Shell script termination with exit function in backquotes

2011-03-13 Thread Maxim Khitrov
On Sun, Mar 13, 2011 at 9:59 PM, Scott Ballantyne boyva...@gmail.com wrote: On Sun, Mar 13, 2011 at 8:26 PM, Maxim Khitrov m...@mxcrypt.com wrote: Hello everyone, I might be doing something dumb here, but this doesn't make sense to me. When I run the following script, I would expect to see

Re: Shell script termination with exit function in backquotes

2011-03-13 Thread Devin Teske
On Mar 13, 2011, at 5:26 PM, Maxim Khitrov wrote: Hello everyone, I might be doing something dumb here, but this doesn't make sense to me. When I run the following script, I would expect to see no output: #!/bin/sh exit_prog() { echo -n 'before' exit 0 echo