#2947 PR merged
: Replace subshell redirection by group command redirection¶
Labels: bug
, cleanup
, fixed / solved / done
jsmeix opened issue at 2023-02-24 12:56:¶
-
Type: Bug Fix / Cleanup
-
Impact: Normal
-
Reference to related issue (URL):
https://github.com/rear/rear/issues/2927#issuecomment-1440044143 -
How was this pull request tested?
not yet tested by me -
Brief description of the changes in this pull request:
In layout/save/GNU/Linux/230_filesystem_layout.sh
and layout/save/GNU/Linux/200_partition_layout
and layout/save/GNU/Linux/240_swaps_layout.sh
replaced the subshell that appends its stdout to DISKLAYOUT_FILE
by a group command with redirection
{
...
} 1>>$DISKLAYOUT_FILE
cf. usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh
https://github.com/rear/rear/blob/rear-2.7/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh#L375
jsmeix commented at 2023-03-01 09:42:¶
Because I like explicit code :-)
When one uses explicit code like '1>>' versus '2>>'
it is easier to grep over the whole code to find all places
where stdout is redirected versus where stderr is redirected
in contrast to '>>' and '2>>' where it is less easy
to find all places where stdout is redirected.
Because explicit code is usually not used in practice
this advantage does not apply in practice.
Nevertheless I prefer explicit code.
For the fun of it an example
output/RAWDISK/Linux-i386/280_create_bootable_disk_image.sh:
StopIfError "Could not compress disk image using <<$RAWDISK_IMAGE_COMPRESSION_COMMAND \"$disk_image\">>"
where neither stdout nor stderr is redirected, cf.
https://github.com/rear/rear/pull/2937#discussion_r1121363326
schlomo commented at 2023-03-01 09:47:¶
yes, I got it. I'll change my quotes to single quotes :-)
[Export of Github issue for rear/rear.]