Hey everyone i have this issue where i have a sample program in csh (i know its not the best language to use for scripting but i dont have an option here) its as foll:
#!/bin/csh
echo 'please enter values'
read a
read -e b
echo "My values are $a and $b"
As you might see my second read is going to take a file input. This is needed as my actual program will have that; now what i want to do is to convert this to alias however when i execute the above script i get the foll. output
please enter values
read: Command not found
read: Command not found
a: Undefined variable
How can i fix this and also i want to convert this all 4 lines into a multiline alias. I have written single line alias in the past with no issues but not sure about multiline. if someone can help out i'll be really grateful
As you have discovered, the C shell does not have a built-in
read
function similar to that of Bourne-type shells.I am not proficient in
csh
synatax but as far as I know, the nearest equivalent is to use the special variable$<
. Fromman csh
:e.g.
which gives
Note that there are implementation-dependent differences in how assignments from
$<
handles multi-word input - in particular, the Tenextcsh
does not quote input by default, instead requiring$<:q
to get the same behavior as BSDcsh
. Also there is (as far as I know) no built-in readline editing support equivalent to the bash shell'sread -e
.As far as multi-line aliases are concerned, they do seem to work:
Testing it
however it's not a feature that I would recommend relying on.