-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxe
More file actions
executable file
·29 lines (25 loc) · 924 Bytes
/
xe
File metadata and controls
executable file
·29 lines (25 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl
# simple xargs escape
# (assume 1 filename per line)
# man 1 find:
# BUGS
# The special characters used by find are also special characters to many shell pro-
# grams. In particular, the characters ``*'', ``['', ``]'', ``?'', ``('', ``)'',
# ``!'', ``\'' and ``;'' may have to be escaped from the shell.
# are those all problems?
# also, space, quotes,
# newline, ctrl chars -- these should maybe be an error
# maybe unicode
# test cases
# - a few files w/ a bunch of chars in their names
# - then binary search to break down into a bunch of smaller names ? single chars ?
# - or just escape everything not 'safe'.
# how does stty settings affect ? or is that only keyboard / pseudo-tty i/o (not pipelines) ?
while (<>) {
s= =\\ =g;
s=([!!@#$%^&*()\[\]\|\\;?<>'"])=\\$1=g;
print;
}
# here's a text:
# touch 'xe-test-[!!@#$%^&*()[]|\;?<>'\''"]'
# echo xe-test-* | xe | xargs rm