Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Use the new TextPrefix function #3166

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

jsmeix
Copy link
Member

@jsmeix jsmeix commented Feb 27, 2024

Use the new TextPrefix function

In lib/_input-output-functions.sh
use the new TextPrefix function
@jsmeix jsmeix added the enhancement Adaptions and new features label Feb 27, 2024
@jsmeix jsmeix self-assigned this Feb 27, 2024
Fix the TextPrefix function:
In the prefix value escape all / by \/
otherwise sed -e "/.../.../" gets invalid syntax
see #3160 (comment)
@jsmeix jsmeix mentioned this pull request Feb 27, 2024
@jsmeix
Copy link
Member Author

jsmeix commented Feb 27, 2024

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
9688568
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.

@jsmeix jsmeix marked this pull request as draft February 28, 2024 12:56
@jsmeix jsmeix changed the title Use the new TextPrefix function WIP: Use the new TextPrefix function Feb 28, 2024
Copy link

Stale pull request message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adaptions and new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant