11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

add the commands to /etc/bash.bashrc.local<br />

To set up on login, add the command:<br />

. /cdll<br />

For example if cdll is in your local home <strong>di</strong>rectory:<br />

. ~/cdll<br />

If in /usr/bin then:<br />

. /usr/bin/cdll<br />

If you want to use this instead of the buitin cd command then add:<br />

alias cd=’cd_new’<br />

We would also recommend the following commands:<br />

alias @=’cd_new @’<br />

cd -U<br />

cd -D<br />

Appen<strong>di</strong>ce A. Script aggiuntivi<br />

If you want to use cdll’s prompt facilty then add the following:<br />

CDL_PROMPTLEN=nn<br />

Where nn is a number described below. Initially 99 would be suitable<br />

number.<br />

Thus the script looks something like this:<br />

######################################################################<br />

# CD Setup<br />

######################################################################<br />

CDL_PROMPTLEN=21 # Allow a prompt length of up to 21 characters<br />

. /usr/bin/cdll # Initialise cdll<br />

alias cd=’cd_new’ # Replace the built in cd command<br />

alias @=’cd_new @’ # Allow @ at the prompt to <strong>di</strong>splay history<br />

cd -U # Upload <strong>di</strong>rectories<br />

cd -D # Set default action to non-posix<br />

######################################################################<br />

The full meaning of these commands will become clear later.<br />

There are a couple of caveats. If another program changes the <strong>di</strong>rectory<br />

without calling cdll, then the <strong>di</strong>rectory won’t be put on the stack and<br />

also if the prompt facility is used then this will not be updated. Two<br />

programs that can do this are pushd and popd. To update the prompt and<br />

stack simply enter:<br />

cd .<br />

Note that if the previous entry on the stack is the current <strong>di</strong>rectory<br />

then the stack is not updated.<br />

Usage<br />

=====<br />

cd [<strong>di</strong>r] [0-9] [@[s|h] [-g ] [-d] [-D] [-r] [<strong>di</strong>r|0-9] [-R]<br />

[|0-9] [-s] [-S] [-u] [-U] [-f] [-F] [-h] [-H] [-v]<br />

Go to <strong>di</strong>rectory<br />

757

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!