joerg@j-hohwiller.de (Jörg Hohwiller) writes:
|> I have a script lets call it yyy that determines a special directory
|> depending on the arguments parsed. What I want is a way to have
|> a simple command that parses all its args to yyy and then cds to the
|> resulting directory of yyy.
|> Did not get it?
|> Example:
|> [~]# yyy gcc
|> /usr/src/Sources/gcc
|> [~]# cd /usr/src/Sources/gcc
|> [gcc]#
|>
|> What I want is to have a command that does both commands above.
|> I read the damn long bash manpage and could not find a way for a
|> script to change the actual working directory (tried popd, etc.)
|> so my last chance was something with alias
|> alias mycd='cd $(yyy $@)'
|> damn aliases are just a replacement of the command, so yyy does not
|> get any args if you call e.g. mycd gcc.
Use a shell function.
mycd () { cd $(yyy "$@"); }
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."