From: Thomas Luedeke Date: 2008-08-13T01:15:43+09:00 Subject: Re: Problems with accessing directory defined in ENV variables Robert Klemme wrote: > On 12 Aug., 01:06, Thomas Luedeke wrote: >> back. >> >> Just for my newbie education, what was going wrong with what I was >> doing? ?What was Ruby thinking I was asking for?? > > You made things more complicated than necessary - probably because of > a shell programming background. In a shell it is a good idea to > enclose every variable expansion in double quotes because this will > prevent issues with whitespace in variable values. Ruby works quite > differently and the expression ENV['TMPDIR'] yields a single string - > even if there are spaces in $TMPDIR. > > But since you choose to employ string interpolation, the result of the > expression in #{} was incorporated into the string, which happened to > have whitespace at the front and rear. Thus the resulting string also > had whitespace at the front and read and that path does not exist on > your filesystem. You can easily see it by doing > > ruby -e 'p " #{ENV['TMPDIR']} "' > > HTH > > Kind regards > > robert Admittedly, I'm having a terrible time understanding what Ruby wants with respect to parentheses, #{} constructs, and the like. It's very confusing. My scripts are a horrible mess because I can't get things to work consistently, and almost every time I refer to a variable, a directory, or a file, I have to write a mini-script just to figure out what it wants. It sucks. -- Posted via http://www.ruby-forum.com/.