in reply to passing setup via pipeline
Presuming your aliases are defined in .aliases (and in bourne shell compatible syntax), this should work:
my $run_cmd = 'l'; open(COM, ". .aliases\n$run_cmd 2>&1 |") || die "Could not execute com +mand\n"; ...
Note that there must be a newline (not a semicolon) after sourcing the .aliases file, because aliases cannot be used on the same line that they are defined.
P.S.: not all shells will by default expand aliases, unless in interactive mode. For example, sh does, while bash does not (even if sh is just a symlink to bash), but you can explicitly enable the feature via shopt -s expand_aliases. Hence, the above example only works because perl calls /bin/sh -c behind the scenes (at least typically — check with perl -V:sh).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: passing setup via pipeline
by Anonymous Monk on May 25, 2010 at 15:06 UTC |