bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

$PS5, for sh -v!


From: 積丹尼 Dan Jacobson
Subject: $PS5, for sh -v!
Date: Wed, 04 Apr 2018 11:25:26 +0800

$PS4 is for sh -x. Well, $PS5 or $PSv should be for sh -v!

Imagine, with just a simple PS5='$ ', one could produce
perfect dialogues,

$ set -eu /tmp/x
$ mkdir $@
$ cd $@
$ seq 3|xargs touch
$ ls -U $@
3  2  1
$ mv -v $@ /var$@
created directory '/var/tmp/x'
copied '/tmp/x/1' -> '/var/tmp/x/1'
copied '/tmp/x/2' -> '/var/tmp/x/2'
copied '/tmp/x/3' -> '/var/tmp/x/3'
removed '/tmp/x/3'
removed '/tmp/x/2'
removed '/tmp/x/1'
removed directory '/tmp/x'
$ ls -U /var$@
3  1  2
$ rm -vr /var$@
removed '/var/tmp/x/3'
removed '/var/tmp/x/1'
removed '/var/tmp/x/2'
removed directory '/var/tmp/x'

all ready for the classroom, or textbook publisher, instead of just a jumbled

set -eu /tmp/x
mkdir $@
cd $@
seq 3|xargs touch
ls -U $@
3  2  1
mv -v $@ /var$@
created directory '/var/tmp/x'
copied '/tmp/x/1' -> '/var/tmp/x/1'
copied '/tmp/x/2' -> '/var/tmp/x/2'
copied '/tmp/x/3' -> '/var/tmp/x/3'
removed '/tmp/x/3'
removed '/tmp/x/2'
removed '/tmp/x/1'
removed directory '/tmp/x'
ls -U /var$@
3  1  2
rm -vr /var$@
removed '/var/tmp/x/3'
removed '/var/tmp/x/1'
removed '/var/tmp/x/2'
removed directory '/var/tmp/x'

when using this script,

PS5='$ '
set -v
set -eu /tmp/x
mkdir $@
cd $@
seq 3|xargs touch
ls -U $@
mv -v $@ /var$@
ls -U /var$@
rm -vr /var$@

In fact $PS5 could even be dynamically expanded just like some other $PS's.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]