forked from pflanze/chj-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_touchy
executable file
·64 lines (52 loc) · 1.09 KB
/
_touchy
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/perl -w
# Thu Aug 4 01:10:57 EDT 2011
(my $email='XXX%YYY,ch')=~ tr/%,/@./;
use strict;
$0=~ /(.*?)([^\/]+)\z/s or die "?";
my ($mydir, $myname)=($1,$2);
sub usage {
print STDERR map{"$_\n"} @_ if @_;
print "$myname [string(s)]
or read lines from stdin.
'url2filename'-escape the strings, create file or bark if exists.
(Christian Jaeger <$email>)
";
exit (@_ ? 1 : 0);
}
use Getopt::Long;
our $verbose=0;
#our $opt_dry;
GetOptions("verbose"=> \$verbose,
"help"=> sub{usage},
#"dry-run"=> \$opt_dry,
) or exit 1;
use Chj::Web::FileescapeUrl qw(fileescapeurl);
use Chj::xsysopen;
sub xtouchy {
my ($str)=@_;
my $path= fileescapeurl($str);
$path.=" " if $path=~ /~$/;
xsysopen $path, O_CREAT|O_EXCL|O_WRONLY;
}
sub touchy {
my ($str)=@_;
my $r;
eval {
xtouchy $str;
$r=1;
};
$r or do {
warn $!
#heh funny, xsysopen doesn't mention the path. whatever.
};
}
if (@ARGV) {
foreach (@ARGV){ touchy $_ };
} else {
while (<STDIN>) {
chomp;
touchy $_
}
}
#use Chj::ruse;
#use Chj::Backtrace; use Chj::repl; repl;