easyoptions icon indicating copy to clipboard operation
easyoptions copied to clipboard

Add osx compatibility for sed regular expression

Open pamtrak06 opened this issue 8 years ago • 1 comments

pamtrak06 avatar Nov 24 '16 22:11 pamtrak06

It would also be a good time to get rid of the sed|sed -- one sed is enough, with multiple -e strings, or one string separated by (quoted) semicolons

On Thu., 5 Apr. 2018, 08:21 Carl-Erik Kopseng, [email protected] wrote:

@fatso83 commented on this pull request.

In bash/easyoptions.sh https://github.com/renatosilva/easyoptions/pull/9#discussion_r179270369:

show_error() { echo "Error: $1." >&2 echo "See --help for usage and options." >&2 }

parse_documentation() { documentation="$(grep "^##" "$(which "$0")")(no-trim)"

  • documentation=$(echo "$documentation" | sed -r "s/## ?//" | sed -r "s/@script.name/$(basename "$0")/g" | sed "s/@#/@/g")
  • documentation=$(echo "$documentation" | $SED_REGEX "s/## ?//" | $SED_REGEX "s/@script.name/$(basename "$0")/g" | sed "s/@#/@/g")

Great with better compatibility, but there is nothing here that really demands the POSIX extensions, except the ?, which could be simply replaced with {0,1}. As in

sed -e 's/## {0,1}//'

That would simply get away with all the os detection, falling back to standard sed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/renatosilva/easyoptions/pull/9#pullrequestreview-109484759, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMChaeThUxbtJxg9CsKiF1Mlp4vLB0tks5tlStUgaJpZM4K7-_v .

kurahaupo avatar Apr 04 '18 22:04 kurahaupo