简体   繁体   中英

Pass arguments to set-alias in modulefile

I try to load a modulefile containing an alias from a bash shell. The tutorial page says the following about the set-alias command:

set-alias alias-name alias-string

Sets an alias or function with the name alias-name in the user's environment to the string alias-string. Arguments can be specified using the Bourne Shell style of function arguments. If the string contains "$1", then this will become the first argument when the alias is interpreted by the shell. The string "$*" corresponds to all of the arguments given to the alias. The character '$' may be escaped using the '\\' character.

For some shells, aliases are not possible and the command has no effect. For Bourne shell derivatives, a shell function will be written (if supported) to give the impression of an alias. When a modulefile is unloaded, set-alias becomes unset-alias.

I want to use an alias to create a command that lets me start a given software with some specific parameters. Can anyone please point out what is wrong with the syntax below?

set-alias    cmd     "cmd $1 -cnf=/shared/$2 -ssh -etc"

Because module scripts are written in Tcl, you need to quote Tcl metacharacters in the alias-string . The simplest way to do this is to put the alias in { braces } instead of " double-quotes " .

set-alias cmd {cmd $1 -cnf=/shared/$2 -ssh -etc}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM