Search code examples
shellunixaliascsh

Unix symbol \!* in alias cd 'chdir \!* && set prompt="${cwd} >"'


I'm unable to understand use of symbol \!* in the following alias statement alias cd 'chdir \!* && set prompt="${cwd} >"'. This is related to csh


Solution

  • The alias defines a command. This command can be launched with arguments, so the pattern !* represents the arguments that will be passed to the alias. For the definition to be correct, the symbol ! is de-specialized with \! to prevent the replacement to operate during the alias definition but during the alias usage.

    If you call it with cd a b c d, this would be like you type chdir a b d c d && set prompt="${cwd} >"