2

This is a sample straight forward program. I am using C-shell and want a solution for this environment itself. Following this code sample:

set FILENAME = "\!:2"

alias jo 'echo this is my \!:1 file and its name is $FILENAME'

on command line when I give the following:

jo first sample.txt

I should get the output as

this is my first file and its name is sample.txt

instead I get

this is my first file and its name is !:2

The problem here is the symbol \ totally gets eliminated, I don't know how. That is needed if I want it to take the argument. Can anyone help out with this?

Terrance
  • 43,712

1 Answers1

1

To achieve the desired result, you should wrap the alias' second argument with double quotes, so the variable filename gets interpreted correctly:

set FILENAME = "\!:2"
alias jo "echo this is my \!:1 file and its name is $FILENAME"

Test case:

% jo first sample.txt
this is my first file and its name is sample.txt
0x2b3bfa0
  • 9,110
  • 7
  • 38
  • 55