1

screenshot

Apologies in advance if I am asking an unimportant question, but I can't find any information about this anywhere and it's making me crazy. See image above.

This is taking place in the arch installation shell, and I have been able to reproduce this both in virtualbox and on bare metal booted from a usb. When one first boots from the arch iso, one is presented with a root shell with a zsh prompt that looks like root@archiso ~ # if one enters recognized commands, the prompt stays the same, but if one enters unrecognized commands, then the user field of the zsh prompt changes from root to 1 root on the first command, and then from subsequent commands onwards the prompt becomes 127 root@archiso ~ #

To be clear, the command line still functions, and it's possible to proceed with the installation as usual, but the root prompt being changed in this way is confusing and a little worrying without knowing what might cause this.

I am unfamiliar with zsh so maybe this is a zsh quirk and not an arch linux thing, but I don't know enough to understand what could be causing the username to display some increment. The fact that it stops at 127 seems like a clue since 127 would be the highest value of 7 bits. Is this a bug? Is this somehow exploitable? Has anyone else ever noticed this? Can anyone explain why this might be happening? Thanks for your help!

My PS1 is:

# echo "$PS1"
%B%F{red}%(?..%? )%f%b%B%F{red}%n%f%b@%m %B%40<…<%~%<< %b%#
2
  • Looks like it is simply including the exit status of the last command in the prompt. Please edit your question and add the output of echo "$PS1" so we can see what the default prompt is. But you can confirm by simply running echo $? after every command and you'll see it's the same number.
    – terdon
    Nov 30, 2022 at 17:54
  • Thanks terdon, you're right! echo $? matches the number. But why would the exit status of the previous command be bleeding into the prompt? I added the $PS1 variable Nov 30, 2022 at 18:09

1 Answer 1

1

I found this question.

which explains that

"Zsh includes the ability to display the return code/exit code of the previous command in the prompt by using the %? escape sequence." The %? escape sequence is included in the zsh prompt so I guess this is expected behavior based on a choice that the arch devs made when configuring the zsh prompt for the installation shell.

So that answers the question I guess. Thanks!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .