X-Spam-Check-By: sourceware.org Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Subject: RE: stupid spaces in environment vars Date: Fri, 9 Feb 2007 10:11:22 -0500 Message-ID: <4C89134832705D4D85A6CD2EBF38AE0FC5A31F@PAUMAILU03.ags.agere.com> In-Reply-To: A<1207595.6YXS76RrHQ@teancum> References: A<1207595 DOT 6YXS76RrHQ AT teancum> From: "Williams, Gerald S \(Jerry\)" To: Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id l19FBxJw009178 David Bear wrote: > I would like to have used something like > > cd $USERPROFILE > > in a bash script but since windows insists on putting spaces in > names, this seems impossible. You might be happier writing your scripts in zsh: bash% cd;pwd /home/gsw bash% export SP="silly path" bash% mkdir "$SP" # Note the quotes bash% cd $SP # Oops, forgot to quote! bash: cd: silly: No such file or directory bash% exec zsh # Make it a one-way trip :-) zsh% cd $SP zsh% pwd # Hey, it worked! /home/gsw/silly path Or get used to always using quotes when you use a variable that could possibly contain a space. Trying to pre-escape environment strings for bash gets messy real quick. Yes, I know the real problem usually comes when you try to build command lines in environment variables. You need to separate parameters without splitting paths. You can do this in ZSH as well, either by forcing the old behavior as needed (through expansion options and/or eval, along with built-in support for basically what you're asking for) or by using better array-based methods: zsh% cd;pwd /home/gsw zsh% command="cd ${(q)SP}" # try (qq)/(qqq)/(qqqq) also zsh% echo $command cd silly\ path zsh% eval $command zsh% pwd /home/gsw/silly path zsh% cd;pwd /home/gsw zsh% command=(cd $SP) zsh% $command # no eval needed zsh% pwd /home/gsw/silly path gsw -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/