How do I prefix -p to every argument passed to my function?
Modifying the arguments themselves and creating a new array are both fine.
|
This should work nicely even for complicated arguments with whitespace and worse:
Test:
|
|||||||
|
|
Put the arguments in an array and use bash pattern substitution on them with array substitution and prefix matching:
That replaces the start of each arg with Unfortunately this does not work properly if you have spaces in your arguments. Spaces are preserved properly with If you don't need |
|||
|
|
|
You can preserve the spaces in the
Inside a function you may limit the scope of a modified |
|||
|
|
pgrepand subsequentlystrace. i.e. to strace a bunch of processes, given their names. – Mehrdad Jul 14 '11 at 6:14