LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Environment variables for bash (https://www.linuxquestions.org/questions/programming-9/environment-variables-for-bash-483191/)

htarko 09-13-2006 02:21 PM

Environment variables for bash
 
When I run the set command in the bash shell of my SUSE 10.1 Linux version, I get the usual list of environmental varialbes but at the end of the output there is a very large quantity of text that appears to be a shell script of some kind. What is it? Does it indicate a bug in my system? If I go into the plain old Bourne shell by typing
htarko@linux-betz:~> sh
only the environmental variables are printed and the extra output is gone.

The OS runs fine otherwise. I am enclosing a small fragment of the output. It is very long. Thanks for any help you can give.

htarko@linux-betz:~> set | wc
680 1500 21901

htarko@linux-betz:~>set
ACLOCAL_FLAGS='-I /opt/gnome/share/aclocal'
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
...
XMODIFIERS=@im=local
XNLSPATH=/usr/X11R6/lib/X11/nls
XSESSION_IS_UP=yes
YAST=/sbin/yast
_=set
is=bash
s=/etc/bash_completion.d/yast2-completion.sh
_cd_ ()
{
local c=${COMP_WORDS[COMP_CWORD]};
local s g=0 x C;
local IFS='
';
shopt -q extglob && g=1;
test $g -eq 0 && shopt -s extglob;
case "$(complete -p ${1##*/} 2> /dev/null)" in
mkdir)

;;
*)
s="-S/"
;;
esac;
case "$c" in
\$\(*\))
eval COMPREPLY=\(${c}\)
;;
\$\(*)
COMPREPLY=($(compgen -c -P '$(' -S ')' -- ${c#??}))
;;
\`*\`)
eval COMPREPLY=\(${c}\)
;;
\`*)
COMPREPLY=($(compgen -c -P '\`' -S '\`' -- ${c#?}))
;;
\$\{*\})
eval COMPREPLY=\(${c}\)
;;
\$\{*)
COMPREPLY=($(compgen -v -P '${' -S '}' -- ${c#??}))
;;
\$*)
COMPREPLY=($(compgen -v -P '$' $s -- ${c#?}))
;;
\~*/*)
COMPREPLY=($(compgen -d $s -- "${c}"))
;;
\~*)
COMPREPLY=($(compgen -u $s -- "${c}"))
;;
esac;
for x in ${COMPREPLY[@]};
do
x=${x// /\\ };
x=${x//(/\\(};
x=${x//)/\\)};
x=${x//\{/\\\{};
x=${x//\}/\\\}};
x=${x//\[/\\\[};
x=${x//\]/\\\]};
C=(${C[@]} $x);
done;

...

remount ()
{
/bin/mount -o remount,${1+"$@"}
}
spwd ()
{
( IFS=/;
set $PWD;
if test $# -le 3; then
echo "$PWD";
else
eval echo \"..\${$(($#-1))}/\${$#}\";
fi )
}
startx ()
{
test -x /usr/X11R6/bin/startx || {
echo "No startx installed" 1>&2;
return 1
};
/usr/X11R6/bin/startx ${1+"$@"} 2>&1 | tee $HOME/.X.err
}


Howard Tarko

spirit receiver 09-13-2006 03:57 PM

Those are just some predefined convenience functions that you can use from the console. For example, spwd will return the last two directories of your current working directory:
Code:

ada@barnabas> echo $PWD
/usr/X11/lib/X11/app-defaults
ada@barnabas> spwd
..X11/app-defaults



All times are GMT -5. The time now is 11:45 AM.