Skip to content

Commit 8c2d6cb

Browse files
committed
perl quoting
1 parent a610f1a commit 8c2d6cb

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

+stdlib/+perl/device.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
function [r, cmd] = device(file)
22

3-
cmd = sprintf('''%s'' -e ''($f=shift) && -e $f or exit 1; print +(stat $f)[0]'' ''%s''', stdlib.perl_exe(), file);
3+
c = '($f=shift) && -e $f or exit 1; print +(stat $f)[0]';
4+
if ispc()
5+
k = sprintf('"%s"', c);
6+
else
7+
k = sprintf('''%s''', c);
8+
end
9+
10+
cmd = sprintf('"%s" -e %s "%s"', stdlib.perl_exe(), k, file);
411

512
[s, r] = system(cmd);
613
if s == 0

+stdlib/+perl/inode.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
function [r, cmd] = inode(file)
22

3-
cmd = sprintf('''%s'' -e ''($f=shift) && -e $f or exit 1; print +(stat $f)[1]'' ''%s''', stdlib.perl_exe(), file);
3+
c = '($f=shift) && -e $f or exit 1; print +(stat $f)[1]';
4+
if ispc()
5+
k = sprintf('"%s"', c);
6+
else
7+
k = sprintf('''%s''', c);
8+
end
9+
10+
cmd = sprintf('"%s" -e %s "%s"', stdlib.perl_exe(), k, file);
411

512
[s, r] = system(cmd);
613
if s == 0

+stdlib/+perl/samepath.m

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
function [r, cmd] = samepath(file1, file2)
22

3-
cmd = sprintf('''%s'' -e ''(@ARGV==2) or exit 1; @s1 = stat shift or exit 1; @s2 = stat shift or exit 1; exit(($s1[0]==$s2[0] && $s1[1]==$s2[1]) ? 0 : 1)'' "%s" "%s"', ...
4-
stdlib.perl_exe(), file1, file2);
3+
c = '(@ARGV==2) or exit 1; @s1 = stat shift or exit 1; @s2 = stat shift or exit 1; exit(($s1[0]==$s2[0] && $s1[1]==$s2[1]) ? 0 : 1)';
4+
if ispc()
5+
k = sprintf('"%s"', c);
6+
else
7+
k = sprintf('''%s''', c);
8+
end
9+
10+
cmd = sprintf('"%s" -e %s "%s" "%s"', stdlib.perl_exe(), k, file1, file2);
511

612
s = system(cmd);
713

0 commit comments

Comments
 (0)