Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function instead of alias in C shell login script

Tags:

alias

shell

login

I saw in this topic that you can add a function in the shell login script instead of an alias if you want to use parameters. However, I placed the following code inside my .cshrc file in the section with aliasses:

function gf()
{
    grep -n $1 `find .` | grep -v "can't open"
}

But when I type source .cshrc, I get the error message: Badly placed ()'s. Is the syntax different for a C shell than in a Bash shell? If so, what is the correct syntax?

like image 202
physicalattraction Avatar asked Dec 17 '12 14:12

physicalattraction


1 Answers

Here is my solution:

#!/bin/csh

if ("$1" == "run") goto $2

echo "Now in default mode"

echo "Calling myself"

csh -f dummy run sub1

csh -f dummy run sub2

exit


sub1:

echo "In sub1"

exit

sub2:

echo "In sub2"

exit
like image 178
JDS Avatar answered Oct 13 '22 17:10

JDS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!