bugThe GNU Bourne-Again SHell - Bugs: bug #66923, Manual states that $(cat x) and...

 
 

bug #66923: Manual states that $(cat x) and $(< x) being equivalent not strictly true

Submitter:  None
Submitted:  Tue 18 Mar 2025 01:30:06 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Invalid
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 18 Mar 2025 02:45:51 PM UTC, comment #1: 

A directory is not a file, except under the most implementation-specific interpretation. If you try this construct without using a filename, the behavior is unspecified.

Chet Ramey <chet>
Group administrator
Tue 18 Mar 2025 01:30:06 PM UTC, original submission:  

Quote:

```
The command  substitution $(cat file) can be replaced by the equivalent but faster $(< file).
```

This is not true in one case that can lead to missing an error, namely if you try to read a directory, cat will fail but < will succeed. Compare:

v=$(< /)
v=$(cat /)

Anonymous

 

(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)
  •  

    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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-03-18 chet StatusNone Invalid

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code