public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: cygwin@cygwin.com
Subject: Re: Bash shell script issue
Date: Wed, 07 Sep 2016 18:28:00 -0000	[thread overview]
Message-ID: <eb1c8bc2-6f49-47ae-73ee-7acefd7fefc8@redhat.com> (raw)
In-Reply-To: <15510127987.20160907202742@yandex.ru>


[-- Attachment #1.1: Type: text/plain, Size: 1354 bytes --]

On 09/07/2016 12:27 PM, Andrey Repin wrote:
>> 243d    707b    6f72    656a    7463    725f    6f6f    7d74 
>> 0000120   /   t   o   o   l   s  \r  \n   e   c   h   o       $   x  \r 

                                   ^^^                                ^^

> 
>> Shows there is not "careless editing". 

Umm, those \r ARE carriage returns, as the result of the careless
editing that converted your file to CRLF endings.  Use d2u to strip them
back out.

>> project_root=$PWD
> 
> Still bad.

No, that one's good.  Quotes are only REQUIRED when you want to ensure
that there is no word splitting or globbing going on, and assignment
context has neither of those.  However, although the quotes are optional
in that context, using them out of habit makes it easier to remember to
use quotes in the contexts where it does matter.

> 
>> echo "$project_root"
> 
> Good.
> 
>> x=${project_root}/tools 
> 
> Still bad.

No, that one's okay.  In fact, if you are going for minimalism, you
could use:

x=$project_root/tools

as the ${} form is only REQUIRED when you are using operators inside {}
or when the next character after } is ambiguous with a continuation of
the name of the variable in after the $.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  parent reply	other threads:[~2016-09-07 18:28 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <330568691.2384551.1473201409220.ref@mail.yahoo.com>
2016-09-06 22:39 ` Kipton Moravec
2016-09-07  1:21   ` Eric Blake
2016-09-07  1:41     ` Michel LaBarre
2016-09-07 15:35       ` Kipton Moravec
2016-09-07 15:49         ` Marco Atzeri
2016-09-07 17:41           ` Erik Soderquist
2016-09-07 16:05         ` Andrey Repin
2016-09-07 16:25           ` Kipton Moravec
2016-09-07 16:22     ` Kipton Moravec
2016-09-07 17:35       ` Andrey Repin
2016-09-07 18:09         ` Eliot Moss
2016-09-07 18:28         ` Eric Blake [this message]
2016-09-09 19:37           ` Gene Pavlovsky
2016-09-07 19:16       ` Brian Inglis
     [not found]   ` <32e004cb44addbaefde0839df5500d60@www.ds.net>
     [not found]     ` <039bcc69d005bf6db5aba99a90f51e36@www.ds.net>
2016-09-07 17:54       ` wilson
2016-09-07 18:13         ` Eliot Moss

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=eb1c8bc2-6f49-47ae-73ee-7acefd7fefc8@redhat.com \
    --to=eblake@redhat.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).