Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Service Newsgroups: gnu.bash.bug Subject: built-in '[' and '/usr/bin/[' yield different results Date: Tue, 13 Nov 2018 17:29:42 +0100 Lines: 56 Sender: Service Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: usenet.stanford.edu 1542131060 11704 208.118.235.17 (13 Nov 2018 17:44:20 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; q=dns/txt; c=relaxed/relaxed; d=heinzerling.com; s=dkim; h=Sender:Content-Transfer-Encoding:Content-Type: MIME-Version:Date:Message-ID:Subject:From:To:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=fsXo4ElJZBHCilyrwLHxkhkxMQmQAsRFLEiTmB9k4hQ=; b=1bs8vu8yr4BTUR3ZlTSPa3VdNp 7s2gyLiUId+1EJ0Kr7LB6NnqvWLFzIWTB+E4mWRV9SOe4+ktDIh2owRKZtPW5zUb3j7FxZ/p4RfGX OoHvT+kV7rVOXDh7JXWI3GkGrM9WYCS7YDIsfeTv1jCWnFvxZlP6Qx/xKOd7ih43QTODHN4AdAQuV rhXg+7+Q+h/rkeNxognOG6a0KxwbUJU1TJcaiR06vcHZxvkJbVwi4VQGE2EfKvkbpqhsooMmxOtgF bdj68qKCQP8Ce2qC8UXkjgzBv1psod1q9JBy4qwDIRyhq2F446ptfEtSZhA6OMsspRbi0VhfF6Y2j QJY/YaNg==; X-Authority-Analysis: v=2.2 cv=XsOKARN9 c=1 sm=1 tr=0 a=6uKCkKhFq2wXOH2GoQX8aA==:117 a=9aeJCWYSKC6/ZTgkcEX2MQ==:17 a=IkcTkHD0fZMA:10 a=JHtHm7312UAA:10 a=3KItgHHeXhsA:10 a=OlIbINtc0pbAETKMNzwA:9 a=QEXdDO2ut3YA:10 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 X-EN-UserInfo: 615e7e21fd72644a0b5744e57ccc3c2b:931c98230c6409dcc37fa7e93b490c27 X-EN-AuthUser: service@heinzerling.com X-EN-OrigIP: 87.175.11.109 X-EN-OrigHost: p57af0b6d.dip0.t-ipconnect.de X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.96.188.3 X-Mailman-Approved-At: Tue, 13 Nov 2018 12:44:19 -0500 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14812 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