bugThe GNU Bourne-Again SHell - Bugs: bug #67358, Extra space in parameter expansion...

 
 

bug #67358: Extra space in parameter expansion with quoted strings and trailing $.

Submitter:  mohos <mohos>
Submitted:  Sat 26 Jul 2025 05:37:05 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  None Open/Closed:  Open
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Mon 28 Jul 2025 02:53:13 PM UTC, comment #1: 

Thanks for the report. I'll fix it in the devel branch.

Chet Ramey <chet>
Group administrator
Sat 26 Jul 2025 05:37:05 PM UTC, original submission:  

Problem description:
When using parameter expansion with a variable containing a space, and then concatenating it with a string followed by $, an extra leading space appears before the text.

Bash version:
GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)

Steps to reproduce:

export S=" "
echo $S"hello"$
Actual output:
 hello$
Expected output:
hello$
Environment:

OS: Ubuntu 22.04 (Linux 5.15)
Locale: en_US.UTF-8

This behavior does not seem documented in POSIX or in the Bash source code. Please investigate and correct the parameter‑expansion behavior so it matches the expected output.

mohos <mohos>

 

Attached Files

This item currently has no attached files.

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

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

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

    Votes

    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.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

    History

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-07-28 chet StatusNone Fixed

    Back to the top

    Powered by Savane 3.16-598c.
    Corresponding source code