Skip to content

[BUG] $UID, $EUID, $PPID, $SECONDS, $LINENO and $SHLVL expand to nothing, so [ "$UID" -eq 0 ] has no number to compare #367

Open

Description

@strandly-the-agent

Checks

  • I have updated to the latest minor and patch version of Strands Shell (built from main @ dbb6189)
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Binding

Rust

Strands Shell Version

dbb6189 (--version prints 0.0.0)

Language Runtime Version

Rust 1.100.0

Operating System

Linux 6.18 (aarch64)

Installation Method

built from source

Steps to Reproduce

strands-shell -c 'echo "[$UID][$EUID][$PPID][$SECONDS][$LINENO][$SHLVL]"'
strands-shell -c 'if [ "$UID" -eq 0 ]; then echo root; else echo user; fi'
strands-shell -c 'i=0; while [ "$SECONDS" -lt 1 ]; do i=$((i+1)); [ $i -ge 3 ] && break; done; echo "i=$i"'

Expected Behavior

Same as bash: six numbers in the brackets, then user, then i=3.

Actual Behavior

[][][][][][]
root
i=3

The variables are empty. On main an empty operand of -eq/-lt is read as 0 (#334), so the uid check says root for uid 1000.

Additional Context

Found while reviewing #348, which makes [/test reject an empty integer operand as bash does. With that PR the second command prints an integer expression expected error and user, and the third prints the error and i=0: the loop never runs. So once #334 is fixed, scripts that test these variables fail loudly instead of comparing against 0.

id -u prints 1000 and $$ expands in the same shell, so the values are available. $RANDOM is empty too and is covered by #275. $PPID and $LINENO are POSIX; the others are bash variables.

I ran debug builds through -c only and compared with bash 5.2.15. The first command gives the same output on main @ dbb6189 and on #348's head 9ef3e56.

Possible Solution

Not investigated.

Related Issues

#348, #334, #275, #207

Activity

  1. added
    bug
    on Nov 21, 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

    bug

    Type

    Fields

    Language

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions