+ -
当前位置:首页 → 问答吧 → 比较有难度的脚本

比较有难度的脚本

时间:2011-05-11

来源:互联网

这3句是什么意思
PathToMe=$(whence $0)
eval $(${PathToMe%/*}/
$binToMe =~ s:/[^/]*$::;

作者: fufelixzh   发布时间: 2011-05-11

本帖最后由 xiaopan3322 于 2011-05-11 20:43 编辑

请说明环境和上下文……不要让我们去猜……

1. whence是ksh和zsh中的builtin吧(看引用部分),同`whence $0`, 即找出你的脚本的路径,赋值给PathToMe
2. 这条命令不完整,你确定你粘贴对了?
    因为怀疑不完整,所以只能解释下${PathToMe%/*}
    从右向左截取第一个/为分隔符的后面的字符串
    如PathToMe=/home/xxx/yyy/zzz,${PathToMe%/*}处理后为/home/xxx/yyy
3. Perl中的变量处理,将binToMe变量中符合/[^/]*$的删除



QUOTE:
whence is a builtin in ksh and zsh, and does the same job as "type" but
with many options and a different syntax.

See the useful "whence -m " in zsh to search for
commands with a pattern.

$ whence -apm '?sh'
/bin/ash
/usr/bin/ssh
/usr/bin/bsh
/usr/bin/ksh
/usr/bin/zsh
/bin/csh
/usr/bin/rsh

In zsh, "type" is "whence -v", "where" is "whence -ca", "which"
is "whence -c".

作者: xiaopan3322   发布时间: 2011-05-11