Unix Technical Forum

Script Query

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 ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-20-2008, 07:20 AM
No_One
 
Posts: n/a
Default Script Query


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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-20-2008, 07:21 AM
Keith Keller
 
Posts: n/a
Default Re: Script Query

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-20-2008, 07:21 AM
William Hunt
 
Posts: n/a
Default Re: Script Query

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-20-2008, 07:21 AM
Thomas Ronayne
 
Posts: n/a
Default Re: Script Query

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-20-2008, 07:21 AM
No_One
 
Posts: n/a
Default Re: Script Query



Thanks to all for the information, the help is appreciated.

thanks

ken
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:23 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com