简体   繁体   English

为什么“:l”在zsh脚本中消失了

[英]why “ :l ” disappeared in zsh script

I wrote a function in my .zshrc: 我在.zshrc中写了一个函数:

cnj(){
    port=0;
    echo -n "Enter number of port > ";
    read port;

    a="ssh -N -f -L localhost:$port:localhost:$port  name@ip";
    echo $a;
}

the result shows that : 结果表明:

ssh -N -f -L localhost:8909ocalhost:8909 name@ip

why 为什么

:l

disappear in 消失了

localhost:8909ocalhost:8909

This is an instance of the colon modifier syntax . 这是冒号修饰符语法的一个实例。

$var:l in particular converts the contents of $var to lowercase. $var:l特别将$var的内容转换为小写。

To prevent :l being interpreted as modifier you can add braces around the variable name: 要防止:l被解释为修饰符,您可以在变量名称周围添加大括号:

"...${port}:localhost:..."

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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