#3166 PR open
: WIP: Use the new TextPrefix function¶
Labels: enhancement
jsmeix opened issue at 2024-02-27 11:51:¶
Use the new TextPrefix function
-
Type: Enhancement
-
Impact: None
No impact for users.
But for us:
More standardized code by a general TextPrefix function
instead of individualsed
calls.
Easier to find the code places where text is prefixed.
Easier to properly indent multi-line texts in the code. -
Reference to related issue (URL):
https://github.com/rear/rear/pull/3160 -
How was this pull request tested?
https://github.com/rear/rear/pull/3160#issuecomment-1954251341
and
https://github.com/rear/rear/pull/3160#issuecomment-1954258836
jsmeix commented at 2024-02-27 13:50:¶
As always it is more complicated than one thinks,
cf. RFC 1925 item 8.
Something like
COMMAND | TextPrefix '# '
cannot be used in general.
It can only be used when the output of COMMAND
is not indented or when that indentation is meaningless
because TextPrefix removes (meaningful) indentation.
For example the above
https://github.com/rear/rear/pull/3166/commits/9688568ec2d9f7f6031216424c498f1d800822ef
should be OK because plain 'lsdasd' output is not indented
see the example in
http://ubuntu-on-big-iron.blogspot.com/2018/03/ubuntu-ccw-howto-2-of-4-DASD.html
... lsdasd
Bus-ID Status Name Device Type BlkSz Size Blocks
=======================================================================
0.0.2608 active dasda 94:0 ECKD 4096 7043MB 1803060
0.0.2619 active dasdb 94:4 ECKD 4096 21129MB 5409180
...
In contrast e.g. lsdasd -l ...
output is indented
as shown in
https://www.ibm.com/docs/en/linux-on-z?topic=c-lsdasd-2
lsdasd -l 0.0.4d82
0.0.4d82/dasdd/94:12
status: active
type: ECKD
blksz: 4096
...
Another example where COMMAND output indentation
is meaningful and needed is the
"Example 'mdadm --misc --detail $raiddevice' output"
in layout/save/GNU/Linux/210_raid_layout.sh
/dev/md/raid1sdab:
Version : 1.0
Creation Time : Wed Oct 13 13:17:13 2021
Raid Level : raid1
Array Size : 12582784 (12.00 GiB 12.88 GB)
...
where TextPrefix '# '
would result
# /dev/md/raid1sdab:
# Version : 1.0
# Creation Time : Wed Oct 13 13:17:13 2021
# Raid Level : raid1
# Array Size : 12582784 (12.00 GiB 12.88 GB)
# ...
Not a big fault but less readable as the indented output.
[Export of Github issue for rear/rear.]