IRIX的bash shell扩展在单引号前pression,但不应该 [英] IRIX bash shell expands expression in single quotes, yet shouldnt
问题描述
在shell,我进入一个单引号,然后回车,然后一系列的线,然后又单引号:
根@宗旨:/根>
> @stat = LSTAT($ ARGV [0]);
>如果(!@stat){
如果(@stat = LSTAT($ ARGV [0])){
>打印无\\ n;
>退出0;
> }
>
不过,如果你注意到从shell PTED输出间$ P $:
的bash:
@stat = LSTAT($ ARGV [0]);
如果(@stat = LSTAT($ ARGV [0])){
打印无\\ n;
退出0;
}
: 找不到命令
根@宗旨:/根> -a的uname
IRIX64目标6.5 04091957 IP27
根@宗旨:/根>回声$ 0个
-bash
根@宗旨:/根>
您注意到 @静
被转换为 @stat = LSTAT($ ARGV [0]);!
应该如何以下shell程序编写,以便使其中的perl程序得到字面上PTED间$ P $?
tramp_perl_file_attributes(){
\\ perl的-e'
@stat = LSTAT($ ARGV [0]);
如果(!@stat){
打印无\\ n;
退出0;
}
如果(($ STAT [2]&放大器; 0170000)== 0120000)
{
$型=的readlink($ ARGV [0]);
$ TYPE =\\$型\\;
}
ELSIF(($ STAT [2]&安培; 0170000)== 040000)
{
$ TYPE =T;
}
其他
{
$ TYPE =无
};
$ UID =($ ARGV [1] EQ整数)? $ STAT [4]:\\getpwuid($ STAT [4])\\;
$ GID =($ ARGV [1] EQ整数)? $ STAT [5]:\\getgrgid($ STAT [5])\\;
的printf(
(%S%U%s%S(%U%U)(%U%U)(%U%U)%u.0%U T(%U%U)-1)\\ n
$型,
$ STAT [3],
$ UID,
$ GID,
$ STAT [8]≥> 16和; 0xFFFF的,
$ STAT [8]&放大器; 0xFFFF的,
$ STAT [9]≥> 16和; 0xFFFF的,
$ STAT [9]&放大器; 0xFFFF的,
$ STAT [10]≥> 16和; 0xFFFF的,
$ STAT [10]&安培; 0xFFFF的,
$ STAT [7],
$ STAT [2],
$ STAT [1]≥> 16和; 0xFFFF的,
$ STAT [1]&放大器; 0xFFFF的
);' $ 1$ 2
}
逃离!
或禁用历史扩展(与设置+ H)
当你键入命令。
由于某些原因,!
从历史( !!扩大
被扩大到您所键入的最后一个命令在命令行),这不应该单引号之间发生的。
At the shell, I enter a single-quote and then carriage return and then a series of lines and then another single-quote:
root@aim:/root > '
> @stat = lstat($ARGV[0]);
> if (!@stat) {
if (@stat = lstat($ARGV[0]);) {
> print "nil\n";
> exit 0;
> }
> '
However, if you notice the interpreted output from the shell:
bash:
@stat = lstat($ARGV[0]);
if (@stat = lstat($ARGV[0]);) {
print "nil\n";
exit 0;
}
: command not found
root@aim:/root > uname -a
IRIX64 aim 6.5 04091957 IP27
root@aim:/root > echo $0
-bash
root@aim:/root >
You notice that !@stat
gets converted to @stat = lstat($ARGV[0]);
How should the following shell program be written so that the perl program within it gets interpreted literally?
tramp_perl_file_attributes () {
\perl -e '
@stat = lstat($ARGV[0]);
if (!@stat) {
print "nil\n";
exit 0;
}
if (($stat[2] & 0170000) == 0120000)
{
$type = readlink($ARGV[0]);
$type = "\"$type\"";
}
elsif (($stat[2] & 0170000) == 040000)
{
$type = "t";
}
else
{
$type = "nil"
};
$uid = ($ARGV[1] eq "integer") ? $stat[4] : "\"" . getpwuid($stat[4]) . "\"";
$gid = ($ARGV[1] eq "integer") ? $stat[5] : "\"" . getgrgid($stat[5]) . "\"";
printf(
"(%s %u %s %s (%u %u) (%u %u) (%u %u) %u.0 %u t (%u . %u) -1)\n",
$type,
$stat[3],
$uid,
$gid,
$stat[8] >> 16 & 0xffff,
$stat[8] & 0xffff,
$stat[9] >> 16 & 0xffff,
$stat[9] & 0xffff,
$stat[10] >> 16 & 0xffff,
$stat[10] & 0xffff,
$stat[7],
$stat[2],
$stat[1] >> 16 & 0xffff,
$stat[1] & 0xffff
);' "$1" "$2"
}
Escape the !
or disable history expansion (with set +H)
while you type the command.
For some reason, !
is expanded from the history (!!
gets expanded to the last command you typed on the command line) which shouldn't happen between single quotes.
这篇关于IRIX的bash shell扩展在单引号前pression,但不应该的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!