helpThe GNU Bourne-Again SHell - Support: sr #108616, "jobs" shows 'less...


sr #108616: "jobs" shows 'less "$@"' rather than actual argument with function

Submitted by:  None
Submitted on:  Tue 15 Jul 2014 07:13:58 PM UTC  
Category: NonePriority: 5 - Normal
Severity: 3 - NormalStatus: Wont Do
Privacy: PublicAssigned to: None
Originator Email: -unavailable-Open/Closed: Open
Operating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Fri 13 Nov 2015 05:57:46 PM UTC, comment #1:

The question is what the command line looks like when the child is forked, and what is saved in the jobs list.

In the two cases involving aliases, the alias has been replaced by `sleep' before word expansion takes place (or a child is forked) because the parser performs alias expansion.

In the case of the shell function invoking a foreground job (sleep "$@"), you are correct: the command line that is stored in the job structure is the command before word expansion is performed. That is how bash has always done things (and when I say always, I mean back to the pre-bash-1.0 days 27 years ago), and there isn't a good reason to change it now.

In the final case, the entire shell function is run in the background, so running the `sleep "$@"' is performed in the child. In the parent, the command line is the call to sleep_function, and that is what shows up in the jobs list.

FWIW, ksh93 doesn't list the command at all, mksh and dash behave like bash, and zsh displays the expanded command.

Chet Ramey <chet>
Project Administrator
Tue 15 Jul 2014 07:13:58 PM UTC, original submission:

I have an abbreviation "le" for the "less" command (just to save
typing). I originally I had this as a shell function, but I found that
stopped jobs showed up in the "jobs" output as 'less "$@"' rather than
showing the actual argument. Changing it to an alias avoids that problem
(but is obviously less flexible).

A demonstration (for simplicity I'm using sleep rather than less):



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

Attach File(s):

Attached Files
file #31725:  bash-bug.txt added by None (670B - text/plain - Demonstration of bug (didn't show up in original submission))


Depends on the following items: None found

Items that depend on this one: None found


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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


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



    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 13 Nov 2015 05:57:46 PM UTCchetStatusNone=>Wont Do
    Tue 15 Jul 2014 07:17:48 PM UTCNoneAttached File-=>Added bash-bug.txt, #31725

    Back to the top

    Powered by Savane 3.1-cleanup