Am 2008-01-26 16:48:18, schrieb T o n g: > Here is the full OP -- let me try for the last time:
??? > An advanced bash alias expansion question -- > How can I use my aliases or functions in my bash script? > > I have the following alias and function defined in my ~/.bashrc: > > $ alias rd > alias rd='rmdir' > > $ type dt > dt is a function > dt () > { > pushd +$1 > } > > How can I use them in my script? dt here are spome parameters rd ${HOME} > > Looking through the man pages, I think the following content is related > to my question: > > Aliases are not expanded when the shell is not interactive, unless the > expand_aliases shell option is set using shopt. > > [-+]O [shopt_option] > shopt_option is one of the shell options accepted by the > shopt builtin (see SHELL BUILTIN COMMANDS below). If > shopt_option is present, -O sets the value of that option; +O > unsets it. If shopt_option is not supplied, the names and > values of the shell options accepted by shopt are printed on > the standard output. If the invocation option is +O, the > output is displayed in a format that may be reused as input. > > expand_aliases > If set, aliases are expanded as described above under > ALIASES. This option is enabled by default for interac- > tive shells. > > And this is what I've tried: > > $ bash -c 'shopt -s expand_aliases; alias rd' > bash: line 0: alias: rd: not found ----[ '~/.bashrc' ]------------- shopt -s expand_aliases alias rd=rmdir dt() { pushd +$1 } -------------------------------- > Am I hitting a new bug or I'm doing something wrong? Please comment, > otherwise I'm going to file a bug report. shopt must be executed before ANY other commands in ~/.bash_login or ~/.bashrc and the function should be in ~/.bashrc since it is read by non-login-shells Note: I do this successfuly since years... Thanks, Greetings and nice Day Michelle Konzack Systemadministrator Tamay Dogan Network Debian GNU/Linux Consultant -- Linux-User #280138 with the Linux Counter, http://counter.li.org/ ##################### Debian GNU/Linux Consultant ##################### Michelle Konzack Apt. 917 ICQ #328449886 50, rue de Soultz MSN LinuxMichi 0033/6/61925193 67100 Strasbourg/France IRC #Debian (irc.icq.com)
signature.pgp
Description: Digital signature