#3160 PR open
: New TextPrefix function¶
Labels: enhancement
, discuss / RFC
jsmeix opened issue at 2024-02-20 13:41:¶
-
Type: Enhancement
-
Impact: Normal
-
Description of the changes in this pull request:
New TextPrefix function to
remove leading space and tab characters from input lines
and prefix each line with the argument string if specified.
The intent is to be able to properly indent multi-line message strings
in the code and output the message without the code indentation
but prefixed as needed for example like
message="first line
second line
last line"
LogPrint "Message text:$LF$( TextPrefix ' | ' <<<"$message" )"
which results the following output
Message text:
| first line
| second line
| last line
jsmeix commented at 2024-02-20 13:46:¶
I tested it with an adapted ErrorIfDeprecated()
function ErrorIfDeprecated () {
{ (( $# >= 2 )) || BugError "Must call ErrorIfDeprecated with at least 2 arguments - feature and reason"
local feature="$1" ; shift
local reason="$*"
if IsInArray "$feature" "${DISABLE_DEPRECATION_ERRORS[@]}" ; then
LogPrint "Disabled deprecation error for '$feature'"
return 0
fi
local text="Reason:
$reason
This feature is phased out in ReaR and will be eventually removed.
If it is indispensable, go to https://github.com/rear/rear/issues
and create an issue that explains why there is no alternative to it.
To disable this error and continue using this feature for now, set
DISABLE_DEPRECATION_ERRORS+=( $feature )
"
} 2>>/dev/$DISPENSABLE_OUTPUT_DEV
Error "Deprecation of '$feature'$LF$( TextPrefix '' <<<"$text" )"
}
which results for me this output
# usr/sbin/rear mkrescue
ERROR: Deprecation of 'gpt_sync_mbr'
Reason:
The 'gpt_sync_mbr' partitioning is no longer supported by SUSE since 2016
see https://github.com/rear/rear/issues/3148
This feature is phased out in ReaR and will be eventually removed.
If it is indispensable, go to https://github.com/rear/rear/issues
and create an issue that explains why there is no alternative to it.
To disable this error and continue using this feature for now, set
DISABLE_DEPRECATION_ERRORS+=( gpt_sync_mbr )
jsmeix commented at 2024-02-20 13:51:¶
As another test I replaced in lib/_input-output-functions.sh
some
... | sed -e 's/^/ /' | ...
with
... | TextPrefix | ...
(plain 'TextPrefix' adds two spaces indentation).
jsmeix commented at 2024-02-20 13:53:¶
@rear/contributors
please have a look here and provide feedback
what you think about such a TextPrefix function.
[Export of Github issue for rear/rear.]