Skip to content

prompt expansion incomplete: bare special parameters stay literal and shopt -u promptvars has no effect (plus \! \# HISTCMD PS0 compgen -A signal) #757

Closed

Description

@caomengxuan666

Summary

The prompt-expansion path is incomplete. All of this was reached without a PTY, through ${PS1@P}, so none of it needs an interactive harness to reproduce.

1. Bare special parameters are not expanded

false
PS1='x$?y'
printf '[%s]\n' "${PS1@P}"
result
GNU bash [x0y]
niu / rubash [x$?y] — literal

2. shopt -u promptvars is ignored

MYVAR=xyz
shopt -s promptvars; PS1='A$MYVAR B'; printf '[%s]\n' "${PS1@P}"
shopt -u promptvars;                      printf '[%s]\n' "${PS1@P}"
promptvars on promptvars off
GNU bash [Axyz B] [A$MYVAR B]
niu / rubash [Axyz B] [Axyz B] — still expanded

The option whose entire purpose is to stop prompt expansion has no effect.

3. Lower severity, same sweep — not re-checked by me

  • backticks in a prompt are not expanded even with promptvars on;
  • \! always expands to 1, and $HISTCMD is unset (GNU: 2,3,4… and 6,8,10… across successive prompts);
  • \# is bumped once per PROMPT_COMMAND run rather than once per prompt;
  • PS0 is never emitted (GNU emitted it 4 times in the same probe);
  • compgen -A signal returns 62 names, including two empty entries, and omits DEBUG ERR EXIT RETURN (GNU: 68 names, none empty).

4. Reported to keep it in one place — already covered elsewhere

Why it matters

Prompts are how a login shell reports state, and promptvars off is how a prompt shows a literal $var. \#, \! and HISTCMD are what a prompt uses to show history position. niubash is now used as a login shell under tmux, where this path is the product surface.

Method

LF script files; niu (installed 1.4.0) vs WSL GNU bash 5.3.0; stdout/stderr captured separately. Everything above is reachable through ${PS1@P} / printf, so no PTY was needed — the parts that genuinely need a PTY are listed separately in the sweep and are not claimed here.

Activity

  1. added
    bug
    P2-medium
    area:interactive
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2-mediumarea:interactivebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions