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"
}