Pageferry
Product

Bash exit code, script output and file diffs in a chat card

01

A Bash exit code is the number a command returns when it ends: 0 for success, 1 to 255 for failure. Pageferry runs your script with Shell, reads that number from the real process and puts it in a chat card next to the output. It edits files too, and shows the diff first.

01

Run scripts

Shell runs your Bash script in WSL or over SSH and shows the real exit code in the chat.

02

Read files

read_file and grep show your script in the chat, so you can find where $1 and $2 are used.

03

Edit with a diff

edit_file proposes a change and shows the diff. Under Ask first it waits for your OK.

What the agent can do

How a run looks in the chat

Each action becomes a card in the chat. Shell reports the real exit code, edit_file shows a diff, and Ask first waits for your OK before anything changes. Open a card to read the full output or the full diff.

Four tasks with exit codes and arguments

Check the exit code when an argument is missing

You ask the agent to find out what happens when check.sh gets no argument. read_file opens the script, and Shell runs bash check.sh with nothing after the name. The card shows the real output and the exit code, which is 2 if the script prints its usage line to standard error and ends with exit 2. The bash exit code of the last command sits in $?, and the caller sees only that number, so a script that ends with a clear code is easier to test than one that always returns 1. Shell then runs the script again with two values, and the card should show 0. If the codes surprise you, read the card, then let edit_file propose a fix under Ask first and review the diff.

Parse options with getopts

You type “explain getopt to me” and the agent answers in plain words: getopts is a Bash builtin for short options such as -v or -f file, while getopt is a separate command that also handles long options such as --file and behaves differently between systems. Then read_file opens your script, edit_file adds a getopts loop and you see the diff. Shell runs the script with -v, with -f and with a wrong option, and each card has its own exit code. A wrong option should end with 2, the usual code for wrong usage. For a handful of options a while loop with case and shift is enough, so ask for that version if you prefer it. Accept the diff only after you have read it.

Keep values with spaces in one piece

Passing arguments with spaces to a script fails when the values are not quoted, because the shell splits them into separate words. The agent reads the file with read_file, finds the unquoted $1 and $@, and edit_file proposes double quotes around them. Shell then runs the script with a value such as "two words", and the output shows whether it arrives as one line or as two. One of the tricks to manage command line arguments is shift, which drops the first value so that a loop can walk through the rest, and the agent can add it in the same diff. Under Ask first the edit waits for you. Review the diff, run the test again and compare the two outputs yourself.

Stop on errors with set -eu

Anyone who searches for “bash exit script” is usually looking for the exit builtin: exit N ends the script with status N, while return N only leaves a function. The agent can add set -eu and set -o pipefail at the top, so the script stops on errors and on unset variables, and then it runs the file with bash -n for a syntax check and with bash -x to print each command. If return is not giving the status of the last command, another command usually ran in between, because $? holds only the exit code of the most recent one. The Shell card shows the trace. Read it from the top, compare it with the script and decide whether the edit stays.

What Pageferry does not do

Pageferry is a desktop app for Windows, not a hosted service or a plugin. It is meant only for your own files, your own PC and servers you are authorised to use. You keep the work within that scope, because the agent does not enforce it, and Shell, web and SSH are not limited to the working folder. Code and results can be wrong, so read the diff and test. Secrets that appear in tool output are redacted before they reach the model.

Pageferry for Windows

Run your next Bash script with a visible exit code

Download Pageferry ↗