mainThe GNU Bourne-Again SHell - Support: sr #110741, Unexpected behavior after update...

 
 

sr #110741: Unexpected behavior after update to 5.1.16

Submitter:  Matthias Haller <matzi>
Submitted:  Thu 13 Oct 2022 11:58:32 AM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Works For Me
Privacy:  Public Assigned to:  None
Open/Closed:  Open Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 13 Oct 2022 03:51:47 PM UTC, comment #1: 

Bash-5.1 implements an empty here-document (length 0) by just opening /dev/null and returning that file descriptor, which implements the correct semantics. Why are you relying on an empty here-document expanding to a read-write anonymous file? That is not documented anywhere.

Chet Ramey <chet>
Group administrator
Thu 13 Oct 2022 11:58:32 AM UTC, original submission:  

After an update on my Ubuntu focal computer, I noticed that some bash scripts no longer work. So I tested them on an old machine and they worked as expected. I found that the link /dev/fd/11 points to /dev/null. Here are the results with version 4.2.25 and version 5.1.16:



#!/bin/bash

LANG=C

catch() {
  ls -la "/dev/fd/$__fd"
  catch_out=$("$@" 2>"/dev/fd/$__fd")
  catch_status=$?
  catch_err=$(cat <&${__fd})
  return $catch_status
} {__fd}<<__EOF__
_EOF_

catch ls /nonexisting-file
echo "exit status: $catch_status"
echo "error stream: $catch_err"




BASH="/bin/bash"
BASHOPTS="checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:force_fignore:globasciiranges:histappend:interactive_comments:progcomp:promptvars:sourcepath"
BASH_ALIASES=()
BASH_ARGC=([0]="0")
BASH_ARGV=()
BASH_ARGV0
BASH_CMDS=()
BASH_COMMAND
BASH_COMPLETION_VERSINFO=([0]="2" [1]="11")
BASH_LINENO=()
BASH_REMATCH=()
BASH_SOURCE=()
BASH_SUBSHELL
BASH_VERSINFO=([0]="5" [1]="1" [2]="16" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")
BASH_VERSION="5.1.16(1)-release"

Got:
lr-x------ 1 matzi matzi 64 Oct 13 13:31 /dev/fd/11 -> /dev/null
exit status: 2
error stream:




BASH="/bin/bash"
BASHOPTS="checkwinsize:cmdhist:expand_aliases:extglob:extquote:force_fignore:histappend:interactive_comments:login_shell:progcomp:promptvars:sourcepath"
BASH_ALIASES='()'
BASH_ARGC='()'
BASH_ARGV='()'
BASH_CMDS='()'
BASH_COMMAND
BASH_COMPLETION="/etc/bash_completion"
BASH_COMPLETION_COMPAT_DIR="/etc/bash_completion.d"
BASH_COMPLETION_DIR="/etc/bash_completion.d"
BASH_LINENO='()'
BASH_SOURCE='()'
BASH_SUBSHELL
BASH_VERSINFO='([0]="4" [1]="2" [2]="25" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu")'
BASH_VERSION="4.2.25(1)-release"

Got:

lr-x------ 1 matzi matzi 64 Oct 13 13:32 /dev/fd/11 -> /tmp/sh-thd-1665654508 (deleted)
exit status: 2
error stream: ls: cannot access /nonexisting-file: No such file or directory

Matthias Haller <matzi>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by matzi (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-24 chet StatusNeed Info Works For Me
    2022-10-13 chet StatusNone Need Info

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code