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


Groups > gnu.bash.bug > #16763

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

From Steven McBride <zzymcbride@gmail.com>
Newsgroups gnu.bash.bug
Subject $(<...) fails with nested quoting.
Date 2020-08-16 20:03 -0700
Message-ID <mailman.27.1597668764.2469.bug-bash@gnu.org> (permalink)
References <09b3ac09-97ce-9bf2-fac3-e2d10113143d@gmail.com>

Show all headers | 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