environment

2009-02-13 Thread Antonio Macchi


$ declare +x x

$ x=one

$ ( echo $x; x=two; echo $x )
one
two



subshell inherits "x"?
is this behavior coherent?





cancel

2009-02-13 Thread antonio_macchi
This message was cancelled from within Mozilla.




Re: environment

2009-02-13 Thread Pierre Gaston
On Fri, Feb 13, 2009 at 12:26 PM, Antonio Macchi
 wrote:
>
> $ declare +x x
>
> $ x=one
>
> $ ( echo $x; x=two; echo $x )
> one
> two
>
>
>
> subshell inherits "x"?
> is this behavior coherent?

The environment is designed to be inherited.
The subshell even inherits the shell variables.

I 'm not sure what causes you trouble here or what it could be incoherent with?




Re: environment

2009-02-13 Thread Antonio Macchi



The environment is designed to be inherited.
The subshell even inherits the shell variables.

I 'm not sure what causes you trouble here or what it could be incoherent with?




i think that

$ ( echo $x )

is like

$ bash -c 'echo $x'



I'm on error... but I can't understand why




Re: environment

2009-02-13 Thread Sitaram Chamarty
On 2009-02-13, Antonio Macchi  wrote:
> i think that
>
> $ ( echo $x )
>
> is like
>
> $ bash -c 'echo $x'

it is confusing I agree.  'man bash' and look for the
section 'COMMAND EXECUTION ENVIRONMENT', which essentially
says that a simple command gets a different environment
(namely only the exported variables) than 'commands grouped
with parantheses'.





Re: ca - New bash command proposal

2009-02-13 Thread Chet Ramey
Rolf Brudeseth wrote:
> Andreas Schwab wrote:
>>
>>
>> ca() { (cd "$@" && pwd -P); }
>>
>> Andreas.
>>
>>   
> That works if I want the path to a directory, but it does not let me
> operate on files within the directory.

Once you have the pathname to a directory, you have dozens of tools
available to operate on its contents.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Re: environment

2009-02-13 Thread Chet Ramey
Antonio Macchi wrote:
> 
> $ declare +x x
> 
> $ x=one
> 
> $ ( echo $x; x=two; echo $x )
> one
> two
> 
> 
> 
> subshell inherits "x"?
> is this behavior coherent?

User-specified subshells execute in an environment that is a duplicate
of the parent shell environment, with a couple of exceptions (traps).
It's in the documentation, under COMMAND EXECUTION ENVIRONMENT.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/




Re: Question about redirecting output of spawned processes

2009-02-13 Thread Eric415

Thanks!! For both the answer and the explanation.
-- 
View this message in context: 
http://www.nabble.com/Question-about-redirecting-output-of-spawned-processes-tp21988680p22007884.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.





Fishing for suggestions.

2009-02-13 Thread Joe Murray99

I hope I am asking this in the correct place.

I have a number of video serials that I have downloaded from the archives. 
They are old but have nice plots.  
What I wanted to do was write a bash script that would keep track of what
episode I was watching and return to the next one what I started the script
again.  I also wanted the script to begin playing the next one if I made no
command to stop playing.

My first attempt at this was to setup a hidden file that would keep track of
the next episode.  I then used a case statement that would branch to the
correct episode that was found in the hidden file.

What I wanted to have happen is if I didn't stop execution of the episode to
have the case staement fall through and play the next episode.  If I did
want to stop watching I could use a goto statement that was controled by the
return value from the player I was using.

Now here is the rub.  It seems that, at least in the version of bash I have
in openSuse 11, the case statement will not fall through.  The ;; at the end
of the list of commands for each section is manditory.  But hey no problem I
can just use a goto and jump back up to run the case statement again or use
a goto to brake out and update the hidden file and end the script.  But alas
goto is not supporten.  Yes I know the goto police will fall from the sky
and do horrible things to my persons but I beleive that goto is a very
important command and when used properly will make code much titghter.

I did think of a solution where I use if statements for each episode number
and the reading of the hidden file will allow only that if statement to run. 
But what happens when I want the next epeisode to automaticly start playing? 
I could set a flag for this and recursively call the script again with the
updated hidden file.  But in my way of looking at code this is ugly.

I could write this in C in just a couple of minutes.  But that's not the
point.  My bash scripting leaves a lot to be learned and this is why I am
using bash in the first place.

So to reiterate the situation.  I have a number, say a dozen, video files
that need to be played in order.  I want to use bash to make this happen.  I
also want to stop exicutuon and return to the place I left when I stopped
exicution.  If I didn't stop exicution I want the next video file to play in
order.  And I want an elegant solution ( that's actually the hard part. ) I
really dislike writting crappy code just so it "works."  In my mind if it
does what one wnats but does in in a crapy way it doesn't "work" well.

Thank you all for your help with this.

In the past I have always fallen back on C for a problem like this, mainly
because I know it, and if I ran into any problems I would pull out Steven's
book, May God rest his sole, and the answer would always be there.  But I
think it's time for me to expand my mind a little.  Not to much but just a
little. 
-- 
View this message in context: 
http://www.nabble.com/Fishing-for-suggestions.-tp21992308p21992308.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.