Changing file extension in csh alias

I want to type only the filename of a gcc source that has ".syn" as an extension and copy it, changing the extension to ".c" so it can be compiled.
I do it as follows:

     if (-e $1.syn) then
     /bin/cp $1.syn $1.c
     endif

This works fine, but if I want to repeat the compilation by recovering the previous call using history, the full filename plus the extension ".syn" appears and I have to delete the ".syn" to use my script.

Because so many programs give one an option of typing a filename with or without an ext, there must be a simple way to do this. How is it done?

You could try symbolically linking the .c file to the .syn file rather than copying it, so as soon as the .syn is updated, the .c tracks it, or you could write the rules in your Makefile to deal with it automatically.

1 Like