This is a discussion on Script Query within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I'm the only one using this computer so I have several script files that will only allow one instance ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I'm the only one using this computer so I have several script files that will only allow one instance of some programs to run, for ex. emacs. At any rate, does the following have some significance in bash alias mc='. /usr/share/mc/bin/mc-wrapper.sh' I'm taling about the . space before the /usr/share/mc/bin/mc-wrapper.sh as opposed to not having the dot space. ken |
| |||
| On 2005-04-01, No_One <no_one@no_where.com> wrote: > > At any rate, does the following have some significance in bash > > alias mc='. /usr/share/mc/bin/mc-wrapper.sh' > > I'm taling about the . space before the /usr/share/mc/bin/mc-wrapper.sh > as opposed to not having the dot space. It does: without the '. ', mc-wrapper.sh runs in a subshell. With the '. ', mc-wrapper.sh runs in the current shell. Compare: $ cat testsh #!/bin/bash DONUTS='mmm' $ ~/testsh $ echo $DONUTS $ . testsh $ echo $DONUTS mmm The value of $DONUTS is made part of the current shell using '. '. Incidentally, '. ' is a synonym for the source bash keyword. This may make zero difference to the mc-wrapper.sh script--you'll have to read it to see if it'll have any adverse effects on your current shell if you source it. --keith -- kkeller-usenet@wombat.san-francisco.ca.us (try just my userid to email me) AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom see X- headers for PGP signature information |
| |||
| On Fri, 01 Apr 2005 19:58:02 +0000, No_One wrote: > At any rate, does the following have some significance in bash > > alias mc='. /usr/share/mc/bin/mc-wrapper.sh' > > I'm taling about the . space before the /usr/share/mc/bin/mc-wrapper.sh > as opposed to not having the dot space. That particular syntax creates an alias for 'mc', which is executed instead of mc when mc is invoked. The alias created uses the bash '.' syntax, which is equivalent to the bash 'source ' syntax. These have the effect of merging the target script (mc-wrapper.sh) into the currently running bash environment, every time mc is invoked. Thus, any environmental statements within mc-wrapper.sh become art of the current environment, and any executable statements are executed at that time. man bash for all the juicy details and more. -- William Hunt, Portland Oregon USA |
| |||
| No_One wrote: >I'm the only one using this computer so I have several script files that will >only allow one instance of some programs to run, for ex. emacs. > >At any rate, does the following have some significance in bash > >alias mc='. /usr/share/mc/bin/mc-wrapper.sh' > >I'm taling about the . space before the /usr/share/mc/bin/mc-wrapper.sh >as opposed to not having the dot space. > > >ken > > The "dot space" is used in Bourne (sh) and Bourne-compatible (bash, ksh) shell programs so the command runs in the current shell (and affects the current environment). Without the dot-space, every command you enter forks and executes the command (called fork and exec); your parent shell (probably your login shell) creates a child shell that inherits its environment from the parent (that's the fork), executes the program (that's the exec), then dies (exits). Nothing that happens in the child affects the parent (this is why you can't change environment variables in a shell program and have them set when the shell program exits -- *unless* you use the "dot-space," in which case the program executes in the parent, no child is created). So, whatever mc-wrapper.sh does, it does it to the parent process. |