[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
issues in bash found while creating command result display
From: |
Paul Wise |
Subject: |
issues in bash found while creating command result display |
Date: |
Sun, 14 Apr 2019 13:28:38 +0800 |
User-agent: |
Evolution 3.30.5-1 |
Hi folks,
I wanted a way in bash to print the status of the last command I ran,
including information about each command in a pipe and about signals.
I noticed that bash does not have the ability to display a command
result, so I came up with the attached prompt configuration.
I am hoping that folks here are interested in fixing the things that I
found that I had to workaround:
* The command number variable $# is not available at the time that the
PROMPT_COMMAND is run, only when $PS1 is evaluated.
* There isn't an easy way to detect no command run yet, syntax errors,
Ctrl+C, Enter etc versus a command being run and exiting
* Sometimes PIPESTATUS isn't reset even though $? has been reset
I am hoping that folks here have suggestions or fixes for the
things that I found I wasn't able to do:
* Determine if a command exited normally or due to a signal, even if
it exited normally with an exit code greater than 128.
* Have the PIPESTATUS be correct after a Ctrl+Z.
* Differentiate between Ctrl+C Ctrl+C and Ctrl+C Enter.
* Disable the status display after tab completion output.
* Disable the status on the first line of the terminal after using the
the terminal clearing functionality of GNOME Terminal.
I am hoping that folks here are interested in adding native support for
displaying command status, possibly like this:
* a PS5 variable that would be evaluated and displayed before the
display of the PS1 prompt and after every exit of a command or
Ctrl+C/Ctrl+Z/etc but not after syntax errors
* a STATUS_COMMAND variable that would be run before evaluation of the
PS5 variable to support customising it dynamically
--
bye,
pabs
https://bonedaddy.net/pabs3/
status-prompt.bash
Description: Text document
signature.asc
Description: This is a digitally signed message part