Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16763

$(<...) fails with nested quoting.

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Steven McBride <zzymcbride@gmail.com>
Newsgroups gnu.bash.bug
Subject $(<...) fails with nested quoting.
Date Sun, 16 Aug 2020 20:03:34 -0700
Lines 60
Approved bug-bash@gnu.org
Message-ID <mailman.27.1597668764.2469.bug-bash@gnu.org> (permalink)
References <09b3ac09-97ce-9bf2-fac3-e2d10113143d@gmail.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding base64
X-Trace usenet.stanford.edu 1597668765 19223 209.51.188.17 (17 Aug 2020 12:52:45 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org, bash@packages.debian.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=+jnbGzmS/+G87OMfADc3APEph1YHc9SIcwiZKsLOR0w=; b=ircGfuZrvnwSTw3Edgtymf/gZ7CoZHQe2H5G4KG/VyaBpAv24vsPWtwVSulg0mTaPs JdOFweAuxbWqZTKe8Jt9JXlGNoqGG8P5WD5iCoOnVr61cLPFcAUPBwDNkm6XzBkk34i7 OpI6l4rnie7rxapXL7u0I+V9b2ye2OhmzQ/nrd0NGd0MKOlfDf4B8G5CXUIOZ51U5JKF jwAgWJU7j/+2RQSU1Ox06ysSzOrQvGd4fI4vLen3iTWKG3BV9aIFeX4ci5+ohXFl496/ bq7hW1MiWfqR/g+MsOqEr64C7DeZxqmRI+h9ekaSPU/Tv6+MpkvrTNuqaHnu1Gqa9zwh gJkA==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=+jnbGzmS/+G87OMfADc3APEph1YHc9SIcwiZKsLOR0w=; b=rPahKqFYDWAo4fAgwqYmIu28ueHEIlN5+GD3QLLFNU219oymUFgy3u9UvUedsQ6Inv 02SU4n20HDGImQEGY/0ljuxzumLDA9ttEkbBwsfh2kSbqZerkGpJIYdaeIEx7CR01XFw 4mvdeCclIU3485iWC2x5Xw2Dct4Hhx7fnkL3sdPnmIvvU04LXsUuniwrIaBsR2zIVU3L 0P8QpiI1sXThyqZ9QD4eOWJzlPcT0pI92u2fXuNWwsV4ikpquCHOcjak8sHDmXgOAOAh I5YqNrKOjFD/PYwAtroFKtRovH3rkydhz4mN0I2CBtROxW8fb9CDCUg7F3Sfj5TCwLfq 4uKA==
X-Gm-Message-State AOAM533lTYvePMg8mKgcj+G1WTZnV6wVrUaQ+9GYzoPcTLvLF6tvyQiA Vq88RyZB3dkNZa2MGwQ3Vvc=
X-Google-Smtp-Source ABdhPJwbqzo9YPhGsuk7cPd+8TmYksb/MN5VZllZKNlzTrWhUM1Thg8CarmT8vlK6rWmMixZNlSevg==
X-Received by 2002:a17:902:43:: with SMTP id 61mr10167642pla.16.1597633415702; Sun, 16 Aug 2020 20:03:35 -0700 (PDT)
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0
Content-Language en-US
Received-SPF pass client-ip=2607:f8b0:4864:20::102c; envelope-from=zzymcbride@gmail.com; helo=mail-pj1-x102c.google.com
X-detected-operating-system by eggs.gnu.org: No matching host in p0f cache. That's all we know.
X-Spam_score_int -20
X-Spam_score -2.1
X-Spam_bar --
X-Spam_report (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action no action
X-Mailman-Approved-At Mon, 17 Aug 2020 08:52:43 -0400
X-Content-Filtered-By Mailman/MimeDel 2.1.23
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <09b3ac09-97ce-9bf2-fac3-e2d10113143d@gmail.com>
Xref csiph.com gnu.bash.bug:16763

Show key headers only | View raw


Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' 
-DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  
-Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
-fdebug-prefix-map=/build/bash-N2nMjo/bash-4.4.18=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security
uname output: Linux tau5vbub1 4.15.0-112-generic #113-Ubuntu SMP Thu Jul 
9 23:41:39 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 20
Release Status: release

Description:
         'echo "$(<\"filename\")"' fails with No such file or directory 
error.
     'echo "$(cat \"filename\")"'  also fails no such file or directory 
error.
     'echo "$(<filename)"' is okay.
     'echo $(<"filename")' is okay.
     I think I'm doing the nested double quoting correctly.
     The quoting is because in my original case 'filename' was
     a variable that could contained a filename with spaces in it.
     My execution trace:
       ~ 19>cat fn
       w1 w2
       ~ 20>echo $(<fn)
       w1 w2
       ~ 21>echo $(<"fn")
       w1 w2
       ~ 22>echo "$(<fn)"
       w1 w2
       ~ 23>echo "$(<\"fn\")"
       -bash: "fn": No such file or directory
     Running "strace" shows that quote marks are not removed in
     the failing case:
     echo "$(<fn)":
         [pid  3708] dup2(4, 1)                  = 1
         [pid  3708] close(4)                    = 0
         [pid  3708] close(3)                    = 0
         [pid  3708] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
      >> [pid  3708] openat(AT_FDCWD, "fn", O_RDONLY) = 3
         [pid  3708] read(3, "some text\n", 128) = 10
         [pid  3708] write(1, "some text\n", 10 <unfinished ...>
         [pid  3707] <... read resumed> "some text\n", 128) = 10
         [pid  3708] <... write resumed> )       = 10
     echo "$(<\"fn\")":
         [pid   779] dup2(4, 1)                  = 1
         [pid   779] close(4)                    = 0
         [pid   779] close(3)                    = 0
         [pid   779] rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
      >> [pid   779] openat(AT_FDCWD, "\"fn\"", O_RDONLY) = -1 ENOENT 
(No such file or di
         [pid   779] openat(AT_FDCWD, "/usr/share/locale/locale.alias", 
O_RDONLY|O_CLOEXE
         [pid   779] fstat(3, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
Repeat-By:
     echo w1 w2 > filename
         echo "$(<\"filename\")"


Fix:
     [Description of how to fix the problem.  If you don't know a
     fix for the problem, don't include this section.]


Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

$(<...) fails with nested quoting. Steven McBride <zzymcbride@gmail.com> - 2020-08-16 20:03 -0700

csiph-web