Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14812
| From | Service <service@heinzerling.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | built-in '[' and '/usr/bin/[' yield different results |
| Date | 2018-11-13 17:29 +0100 |
| Message-ID | <mailman.3984.1542131060.1284.bug-bash@gnu.org> (permalink) |
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-vEMnMR/bash-4.4.18=. -fstack-protector-strong -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security uname output: Linux COOL4 4.4.0-17134-Microsoft #345-Microsoft Wed Sep 19 17:47:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux Machine Type: x86_64-pc-linux-gnu Bash Version: 4.4 Patch Level: 19 Release Status: release Description: It seems that the built-in 'test' does not work properly when run in a sub-shell. Repeat-By: Under Windows 10, WSL. Start "bash", terminal with shell pops up. 1. This works when typed directly: # make everything explicit export PATH="" # ensure that file1 exists and that file2 does not exist /bin/touch file1 /bin/rm -f file2 # built-in if [ file1 -nt file2 ]; then echo nt; else echo not_nt; fi # external if /usr/bin/[ file1 -nt file2 ]; then echo nt; else echo not_nt; fi # Output is as expected: nt nt 2. This does not work: # Put the above commands into a script, say check.sh # Run with: /bin/sh < check.sh # Or : /bin/sh ./check.sh # Or : /usr/bin/env ./check.sh # Output is always not ok: not_nt nt
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
built-in '[' and '/usr/bin/[' yield different results Service <service@heinzerling.com> - 2018-11-13 17:29 +0100
csiph-web