public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Robert Klemme <shortcutter@googlemail.com>
To: cygwin <cygwin@cygwin.com>
Subject: Re: cygwin bash script suddenly can't find ls, grep
Date: Wed, 15 Oct 2014 09:41:00 -0000	[thread overview]
Message-ID: <CAM9pMnOqbfRQvLiNb0Ea7JpnA5Y09tRteXAmyF4OH_n=Ce8=QQ@mail.gmail.com> (raw)
In-Reply-To: <543D8D84.5050302@molconn.com>

On Tue, Oct 14, 2014 at 10:54 PM, LMH <lmh_users-groups@molconn.com> wrote:
> Thorsten Kampe wrote:
>> * LMH (Sat, 11 Oct 2014 20:30:07 -0400)
>>> Good Lord, I guess I wasn't thinking very clearly trying to use
>>> PATH as
>>> a variable for something else. I changed to,
>>>
>>> FILE_DIR=$(ls -d './'$SET'/'$FOLD'/'$FOLD'_anneal/'$PARAM_SET'/'$AN_SET)
>>> echo $FILE_DIR
>>>
>>> FILE_LIST=($(ls $FILE_DIR'/'*'out.txt' ))
>>> echo ${FILE_LIST[@]}
>>
>> That looks pretty ugly. You probably can replace all that with
>>
>> FILE_LIST=(./$SET/$FOLD/$FOLD_anneal/$PARAM_SET/$AN_SET/*out.txt)

More suggestions:

1. use lowercase variable names for variables used only inside your
script. Since variable names are case insensitive it will avoid
collisions like this and also improve readability of the code.
2. In bash you can set shell option "nullglob" to avoid a one element
array with the glob pattern if there is no matching file. In zsh it's
"setopt NULL_GLOB" I believe.
3. Since we do not know whether there are spaces in variables I would
replace the line above with (including suggestion 1):

file_list=("$set/$fold/$fold_anneal/$param_set/$an_set"/*out.txt)

Kind regards

robert


-- 
[guy, jim].each {|him| remember.him do |as, often| as.you_can - without end}
http://blog.rubybestpractices.com/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

      reply	other threads:[~2014-10-15  9:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-12  0:05 LMH
2014-10-12  0:17 ` Ken Brown
2014-10-12  0:30   ` LMH
2014-10-12  6:08     ` Achim Gratz
2014-10-14 20:53       ` LMH
2014-10-12  8:34     ` Thorsten Kampe
2014-10-14 20:54       ` LMH
2014-10-15  9:41         ` Robert Klemme [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAM9pMnOqbfRQvLiNb0Ea7JpnA5Y09tRteXAmyF4OH_n=Ce8=QQ@mail.gmail.com' \
    --to=shortcutter@googlemail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).