Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

2 alias usage problems and set variable constraint

3 views
Skip to first unread message

ela

unread,
Jan 1, 2010, 1:56:37 AM1/1/10
to

1)
Under tcsh, when i run "ctest /var" through the following alias,

alias ctest 'echo $1; pushd $1'

The screen looks like this:
> ctest /var

/var ~


If I try this one:

alias ctest3 'pushd $1; echo $1'

>ctest3 /var
pushd: No other directory.

could anybody tell me why the $1 system fails in alias? If I type the above
command by:

echo /var; pushd /var

or

pushd /var; echo /var

they both work.

2)

I don't know the problem below:
alias gd 'echo `pwd` > ~/.dirstack; cd $1; set prompt="%{^[[1;30m%}`whoami |
cut -f1 -d'.'``pwd`>%{^[[0m%} ";'

>gd /var
/var: Permission denied.

In fact, if I don't add echo `pwd` > ~/.dirstack, the following alias even
works!

alias cd 'cd $1; set prompt="%{^[[1;30m%}`whoami |
cut -f1 -d'.'``pwd`>%{^[[0m%} "'


Finally, From Sidney Lambe's idea, I would like to modify his code but just
don't know why

set -- $(cat $HOME/.dirstack)

doesn't work in tcsh. How should I use set so all the directories I "cd"
before can be recorded in .dirstack and referred later?

Thanks a lot!


ela

unread,
Jan 1, 2010, 6:55:27 PM1/1/10
to

"ela" <e...@yantai.org> wrote in message
news:hhk6b3$mre$1...@ijustice.itsc.cuhk.edu.hk...

>
> 1)
> Under tcsh, when i run "ctest /var" through the following alias,
>
> alias ctest 'echo $1; pushd $1'

J G Miller pointed out that in csh, $1 should be \!:1

> Finally, From Sidney Lambe's idea, I would like to modify his code but
> just don't know why
>
> set -- $(cat $HOME/.dirstack)
>
> doesn't work in tcsh. How should I use set so all the directories I "cd"
> before can be recorded in .dirstack and referred later?

So the remaining question is how to use set to complete a home-made
directory tcsh manager

set -- $(cat $HOME/.dirstack)

echo

echo "a) $1"
echo "b) $2"
echo "c) $3"

echo

read -s -n1 bb

case "$bb" in

a) cd $1 ;;
b) cd $2 ;;
c) cd $3 ;;

esac


0 new messages