1

I'm trying to write a one liner that sources aliases, then calls one of those newly sourced aliases. My one liner is basically:

alias startEnv sourceAliasFile;runNewAlias

Since I'm using csh, I can't make a function. When I run this, my source executes but my new alias doesn't exist yet and does not execute. Why does this not work and is there a way to get around it?

1

It doesn't work because the alias definition and use are all on one line. You might work around this by writing the alias definition to a temporary file and sourcing that. But aside from that — you need to have the statements on separate lines (semicolons don't count for the parser in this case).

  • It's an interesting one, because doing alias foo ls; alias shows that foo is aliased to ls, so CSH knows that the alias has occurred...(on FreeBSD 10.3) – forquare May 17 '16 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.