Improve sed patch to work without gsed #1224
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #1199
Now am is able to install apps when there is only bsd sed without gnu sed, tested without and with gsed on chimera linux (bsd userland):
(Note the
broken sed detected
message is for testing, I put it where the variable about sed gets set)Explanation:
We check the version of
sed
, if it is not gnu sed the variableNO_SED_I=true
gets set.The sed function will check for
if [ "$NO_SED_I" = true ] && [ "$1" = '-i' ]; then
, if both a true it tries to see if we have gsed, if true it uses gsed by default.If there is no gsed it then applies a workaround that drops the
-i
flag (shift) and puts the sed command in a variable$tmpsedYYY
and finally that variable replaces the file we just editedecho "$tmpsedYYY" > "$1"
all while doing a some sanity checks.If for some reason something goes wrong an error message explaining that situation and asking the error to install gsed is given.