[TxMt] export property list keys as BASH variables
Allan Odgaard
throw-away-1 at macromates.com
Mon Nov 20 10:58:22 UTC 2006
On 20. Nov 2006, at 11:10, Hans-Joerg Bibiko wrote:
> to avoid the ! error you can use '' instead of "" but then it
> complicates a bit the BASH function
! refers to a history event, i.e. something you previously typed,
e.g. !! is previous line, !$ is last argument of previous line, !# is
current line, !#:1 is first argument of first line, etc. These are
actually quite handy, here are some examples:
? 43*37.34*7.45 # do some calculation
eur `!!` # convert the result of last line from euro
# (both ? and eur are custom functions)
chmod a+w /path/to/some/file # make file word writeable
ls -l !$ # check if the file has proper mode
cp some_filename.txt backup_!#:1 # make backup, re-using the name
History substitution can do much more, like even search backwards,
but the above are the most common use-cases for me.
Anyway, in double quoted strings, bash does expand various things,
like $VARIABLES, `code` and these history events. So you definitely
want to use single quoted strings, where the only thing you need to
take care of, is apostrophes.
Why you can’t escape it in a double-quoted string is weird, one
solution though would be to escape it by first closing the string,
i.e.: echo "foo"\!" bar".
As for arrays and sub-shells, I think you mean sub-processes, i.e.
the array cannot be exported to new processes you launch from the
shell (since arrays are bash-only), but would that matter? If you
start a new process, chances are that process is a scripting language
that can parse property lists.
More information about the textmate
mailing list