File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -1232,6 +1232,25 @@ The bottom line is that C<map> and C<»> are not interchangeable, but
1232
1232
using one instead of the other is OK as long as you understand the
1233
1233
differences.
1234
1234
1235
+ = head2 Word splitting in C < « » >
1236
+
1237
+ Keep in mind that C < « » > performs word splitting similarly to how
1238
+ shells do it, so
1239
+ L < many shell pitfalls|http://mywiki.wooledge.org/BashPitfalls > apply
1240
+ here as well (especially when using in combination with C < run > ):
1241
+
1242
+ my $file = ‘--my arbitrary filename’;
1243
+ run ‘touch’, ‘--’, $file; # RIGHT
1244
+ run <touch -->, $file; # RIGHT
1245
+
1246
+ run «touch -- "$file"»; # RIGHT but WRONG if you forget quotes
1247
+ run «touch -- $file»; # WRONG; touches ‘--my’, ‘arbitrary’ and ‘filename’
1248
+ run ‘touch’, $file; # WRONG; error from `touch`
1249
+ run «touch "$file"»; # WRONG; error from `touch`
1250
+
1251
+ Note that C < -- > is required to make it work for
1252
+ L < filenames with leading dashes|http://mywiki.wooledge.org/BashPitfalls#Filenames_with_leading_dashes > .
1253
+
1235
1254
= head1 Scope
1236
1255
1237
1256
= head2 Using a C < once > block
Original file line number Diff line number Diff line change @@ -339,8 +339,24 @@ Runs an external command without involving a shell and returns a L<Proc> object.
339
339
340
340
run 'touch', '>foo.txt'; # Create a file named >foo.txt
341
341
342
- run Q:w{rm >foo.txt}; # Another way to use run, using word quoting for the
343
- # arguments
342
+ run <rm >foo.txt>; # Another way to use run, using word quoting for the
343
+ # arguments
344
+
345
+ If you want to pass some variables you can still use C « < > » , but try
346
+ to avoid using C < « » > as it will do word splitting if you forget to
347
+ quote variables:
348
+
349
+ my $file = ‘--my arbitrary filename’;
350
+ run ‘touch’, ‘--’, $file; # RIGHT
351
+ run <touch -->, $file; # RIGHT
352
+
353
+ run «touch -- "$file"»; # RIGHT but WRONG if you forget quotes
354
+ run «touch -- $file»; # WRONG; touches ‘--my’, ‘arbitrary’ and ‘filename’
355
+ run ‘touch’, $file; # WRONG; error from `touch`
356
+ run «touch "$file"»; # WRONG; error from `touch`
357
+
358
+ Note that C < -- > is required to make it work for
359
+ L < filenames with leading dashes|http://mywiki.wooledge.org/BashPitfalls#Filenames_with_leading_dashes > .
344
360
345
361
A sunk L < Proc > object for a process that L < exited|/routine/exitcode > unsuccessfully
346
362
will throw. If you wish to ignore such failures, simply use L < run > in non-sink context:
You can’t perform that action at this time.
0 commit comments