I know, I know, I should use a modern shell… Anyway, so here is the alias:
alias p4client echo `p4 info | perl -ne 's/Client name: (.*)$/print $1/e'`
I also know there is probably a better way to get the p4 client name. This is just an example. So, can anyone tell me a nice and clean way to get this to evaluate this when I invoke the alias rather than evaluating when the alias is created?
The only trick is backslash escaping the single quotes and surrounding everything else with single quotes:
Though the perl can be simplified:
and the echo and “ are saying capture the output these commands print and print it; just print the output instead (only having perl include the newline instead of stripping it from the p4 output only to have echo re-add it):
though now there’s nothing double-quote-unfriendly left in there, so:
There’s nothing different here from how you would do it in bash except not having an = after p4client.