Complete.Org: Mailing Lists: Archives: linux-help: July 2006:
[linux-help] Re: Dollar Arguments
Home

[linux-help] Re: Dollar Arguments

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: linux-help@xxxxxxxxx
Subject: [linux-help] Re: Dollar Arguments
From: Tom Hull <thull2@xxxxxxx>
Date: Sat, 01 Jul 2006 15:25:39 -0500
Reply-to: linux-help@xxxxxxxxx

Bruce Bales wrote:
> I can find what is contained in $HOME or $PATH by using the command echo 
> $HOME 
> or echo $PATH.  But I often run into other arguments preceded with a "$" 
> which I can't decipher with echo; as in the yum repos where it uses $basearch 
> and fc$releasever.  I know basearch is probably i386 or i586 and 
> fc$releasever is fc5, but often I don't know what is hidden and echo usually 
> doesn't help.  google seems to ignore the "$".
> 
> Is there a way to retrieve this information or a file where it is stored?
> bruce

sounds like those are just ordinary shell variables. somewhere before they
are used there should be a statement that sets them; e.g.:

   basearch=i386

or

   basearch=`uname -m`

which can also be written

   basearch=$(uname -a)

unless there's an export statement, those variables only exist within
the scope of the /bin/sh program that runs the script. an export statement
looks like:

   export basearch

exported variables are inherited by programs run by the shell, including
other shell programs. those variables are accessible through the environment;
see getenv(3)

you'll also see references to shell variables written with braces, e.g.:

   fc${releasever}

there are several variants on this which are useful for shell programmers.

some shell variables are set up by your login shell and exported, so they
are effectively everywhere and easy to check as you note above -- $HOME
and $PATH are two. you can get a list of all active shell variables by
running:

   set

to find out what's going on inside a shell script, you can run the whole
shell script with execution trace on:

   sh -x -c "command"

if you only want to debug a small part of the script, you can edit the
script to turn execution trace on/off by surrounding the part of interest
with these commands:

   set -x

   set +x

the -x flag will have already expanded any shell variables. the -v flag
does a similar trace, but as the command lines are read, so the variable
names are present there. you can combine these.

-- 
/*
  *  Tom Hull * http://tomhull.com/ * http://notesoneverydaylife.com/
  */


-- This is the linux-help@xxxxxxxxx list.  To unsubscribe,
visit http://www.complete.org/cgi-bin/listargate-aclug.cgi


[Prev in Thread] Current Thread [Next in Thread]