With Bash 5.0:
$ bash --help
GNU bash, version 5.0.0(1)-release-(x86_64-pc-linux-gnu)
Usage: bash [GNU long option] [option] ...
bash [GNU long option] [option] script-file ...
GNU long options:
--debug
--debugger
--dump-po-strings
--dump-strings
--help
--init-file
--login
--noediting
--noprofile
--norc
--posix
--pretty-print
--rcfile
--restricted
--verbose
--version
What is this --pretty-print
option? I can't find it in the Bash 5.0 man page, nor the internet! So mysterious :O
The bash printf command is a tool used for creating formatted output. It is a shell built-in, similar to the printf() function in C/C++, Java, PHP, and other programming languages. The command allows you to print formatted text and variables in standard output.
Typically, when writing bash scripts, we use echo to print to the standard output. echo is a simple command but is limited in its capabilities. To have more control over the formatting of the output, use the printf command. The printf command formats and prints its arguments, similar to the C printf() function.
The -v option tells the shell to run in verbose mode. In practice, this means that the shell will echo each command prior to executing the command. This will be useful in locating the line of script that has created an error. We can enable the script execution with the -v option as follows: $ bash -v hello.sh.
Characters in the format string are copied to the output or, if a % is encountered, are used to format an item. In addition to the standard formats, %b causes printf to expand backslash escape sequences (for example \n for newline), and %q outputs an item that can be used as shell input.
Found it 8)
In code source, CWRU/changelog
line 1427:
shell.c
- --pretty-print: new invocation option, currently undocumented, dumps
a pretty-printed version of a shell script given as an argument to
stdout
I just tried it, it works like type
with functions but for entire scripts! Neat. Comments will be removed though!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With