~ecs/public-inbox

g: rtfm: clean up sed expression v1 NEEDS REVISION

Evan Johnston: 3
 g: rtfm: clean up sed expression
 g: rtfm: fix quoting
 g: rtfm: posix compliance

 3 files changed, 6 insertions(+), 3 deletions(-)
Quick note: since this list is used for more than just my dotfiles,
please set format.subjectPrefix to 'PATCH dotfiles'. Thanks!

On Mon Sep 13, 2021 at 6:14 AM UTC, Evan Johnston wrote:
> ---
> bin/g | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/bin/g b/bin/g
> index 12879b9..387962e 100755
> --- a/bin/g
> +++ b/bin/g
> @@ -30,7 +30,10 @@ case "$CMD" in
> "pf") CMD="push -f" ;;
> "r") CMD="rm" ;;
> "rc") CMD="rm --cached" ;;
> - "rtfm") exec man "$(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1)" ;;
> + "rtfm") exec man "$(find /usr/share/man -name "git-*" |
> + sed -e 's:.*/::' -e 's/\..*//' |
> + awk 'BEGIN{srand()}{print rand() * 1000000 "\t" $0}' |
Once we're bringing awk in, let's drop the sed in favor of sub(). We
also don't need the second sed expr - not sure why I had it in the first
place.

In addition, please add a space between the BEGIN block and the second
block.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.d2evs.net/~ecs/public-inbox/patches/10/mbox | git am -3
Learn more about email & git

[PATCH 1/3] g: rtfm: clean up sed expression Export this patch

---
 bin/g | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/g b/bin/g
index cd9e083..6766c48 100755
--- a/bin/g
@@ -30,7 +30,7 @@ case "$CMD" in
	"pf") CMD="push -f" ;;
	"r") CMD="rm" ;;
	"rc") CMD="rm --cached" ;;
	"rtfm") exec man $(find /usr/share/man -name "git-*" | sed "s/.*\///;s/\..*//" | shuf -n1) ;;
	"rtfm") exec man $(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1) ;;
	"s") CMD="status" ;;
	"se") export GIT_EDITOR="$EDITOR" CMD="send-email" ;;
	"sl") CMD="shortlog" ;;
-- 
2.33.0

[PATCH 2/3] g: rtfm: fix quoting Export this patch

---
 bin/g | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/g b/bin/g
index 6766c48..12879b9 100755
--- a/bin/g
@@ -30,7 +30,7 @@ case "$CMD" in
	"pf") CMD="push -f" ;;
	"r") CMD="rm" ;;
	"rc") CMD="rm --cached" ;;
	"rtfm") exec man $(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1) ;;
	"rtfm") exec man "$(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1)" ;;
	"s") CMD="status" ;;
	"se") export GIT_EDITOR="$EDITOR" CMD="send-email" ;;
	"sl") CMD="shortlog" ;;
-- 
2.33.0

[PATCH 3/3] g: rtfm: posix compliance Export this patch

---
 bin/g | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bin/g b/bin/g
index 12879b9..387962e 100755
--- a/bin/g
@@ -30,7 +30,10 @@ case "$CMD" in
	"pf") CMD="push -f" ;;
	"r") CMD="rm" ;;
	"rc") CMD="rm --cached" ;;
	"rtfm") exec man "$(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1)" ;;
	"rtfm") exec man "$(find /usr/share/man -name "git-*" |
		sed -e 's:.*/::' -e 's/\..*//' |
		awk 'BEGIN{srand()}{print rand() * 1000000 "\t" $0}' |
		sort -n | head -n1 | cut -f2-)" ;;
	"s") CMD="status" ;;
	"se") export GIT_EDITOR="$EDITOR" CMD="send-email" ;;
	"sl") CMD="shortlog" ;;
-- 
2.33.0
Quick note: since this list is used for more than just my dotfiles,
please set format.subjectPrefix to 'PATCH dotfiles'. Thanks!

On Mon Sep 13, 2021 at 6:14 AM UTC, Evan Johnston wrote:
> ---
> bin/g | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/bin/g b/bin/g
> index 12879b9..387962e 100755
> --- a/bin/g
> +++ b/bin/g
> @@ -30,7 +30,10 @@ case "$CMD" in
> "pf") CMD="push -f" ;;
> "r") CMD="rm" ;;
> "rc") CMD="rm --cached" ;;
> - "rtfm") exec man "$(find /usr/share/man -name "git-*" | sed -e 's:.*/::' -e 's/\..*//' | shuf -n1)" ;;
> + "rtfm") exec man "$(find /usr/share/man -name "git-*" |
> + sed -e 's:.*/::' -e 's/\..*//' |
> + awk 'BEGIN{srand()}{print rand() * 1000000 "\t" $0}' |
Once we're bringing awk in, let's drop the sed in favor of sub(). We
also don't need the second sed expr - not sure why I had it in the first
place.

In addition, please add a space between the BEGIN block and the second
block.