加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 将参数传递给modulefile中的set-alias

发布时间:2020-12-14 01:19:06 所属栏目:Linux 来源:网络整理
导读:我尝试从bash shell加载包含别名的模块文件. tutorial page对set-alias命令说了以下内容: 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
我尝试从bash shell加载包含别名的模块文件. tutorial page对set-alias命令说了以下内容:

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.

我想使用别名来创建一个命令,让我可以使用一些特定的参数启动给定的软件.任何人都可以请指出下面的语法有什么问题?

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

解决方法

因为模块脚本是用Tcl编写的,所以需要在别名字符串中引用Tcl元字符.最简单的方法是将别名放在{braces}而不是“double-quotes”中.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读