Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
handling spaces in variables
- X-seq: zsh-users 11457
- From: "Alexy Khrabrov" <deliverable@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: handling spaces in variables
- Date: Thu, 26 Apr 2007 18:07:25 -0700
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Ipb5iyyKnBShCoqCK8irEezZ9Mqs+YZl4+DTGypk4QFaXtZA7gRAwvQTwZndfSngVxPfJqqsJphwzJIHwIaABimjeJdBL3NBSIxajPZ+6Ulb4FV2cNYJDGyWE9XUvlTZRE0spP1jjqmLr/yhsCEh3VcuvGGE1UDjqEidBGoVzC8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=EnpOru7ooZm/SOJiO2ZKY9yOQOZpdpvNa6cW2ZWEAJJPyJLLOaA5R+Nn2U/l3lfY7RA5evV4mnPSxlcqVgOEuxQQu9lkbEN8RxMz7dhbG1m35bx46TCTNt4n1RZiiLxPjJhMXy021gKSyNA8gv/3XGVITxI19Mfj0JsCQh94dZs=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
I'm running zsh on MacOSX, and Mac generously sprinkles spaces in
system paths. Thus I had to painfully quote all cases where a
parameter or a variable is passed to system commands. I wonder
whether there's a way to minimize such quoting. Here's an example.
Some Leica cameras write a RAW file along with a JPG. The below
script takes a directory path as a parameter and creates a
subdirectory with the trailing name in a fixed central JPG Archive.
Then it moves all JPG files from the original directory to the newly
created one. The script ended up as follows:
#!/bin/sh
SRC=`basename "$1"`
JPGROOT='/Volumes/Mir/JPG Archive/Leica'
TGT="$JPGROOT/$SRC"
mkdir "$TGT"
mv "$1"/*.JPG "$TGT"
Basically, I have to quote a potentially space-containing variable
anywhere on the right-hand side, and when passing back so system
commands.
Can I somehow declare e.g. TGT a self-escaping variable and avoid
quoting it all the time? I.e., whever I now write "$TGT" on the RHS,
I'd write just $TGT, and zsh would supply the quotes?
Cheers,
Alexy
Messages sorted by:
Reverse Date,
Date,
Thread,
Author