Skip to contentSkip to conversation

dim: replace pipe commands with single sed

PATCH In review Lucas De Marchi 4 participants 4 messages May 9, 2018 – May 17, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dim: replace pipe commands with single sed

A single sed can do the job of taking the second line after a match and it looks simpler.

---

I noticed this while reviewing "[PATCH 2/4] dim: shut up sed broken pipe noise in apply-pull".

 dim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dim +1 -1
index 6b684ba5308c..f7cf255db3e1 100755
@@ -924,7 +924,7 @@ function dim_apply_pull
 
 	cat > $file
 
-	pull_branch=$(sed -e '0,/[gG]it repository at:$/d' $file | head -n 2 | tail -n 1)
+	pull_branch=$(sed -ne '/[gG]it repository at:$/{n;n;p}' $file)
 
 	if [[ -z "$pull_branch" ]] ; then
 		echoerr "no pull request found"
Signature · 6 lines
2.17.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

Now CC the right mailing list. The way dim sets up the repository you can't have individual git configs, e.g. to set a different sendemail.to for dim-tools :(

Lucas De Marchi

Quoted 32 lines · Lucas De Marchi

A single sed can do the job of taking the second line after a match and it looks simpler.

---

I noticed this while reviewing "[PATCH 2/4] dim: shut up sed broken pipe noise in apply-pull".

 dim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dim +1 -2
index 6b684ba5308c..f7cf255db3e1 100755
@@ -924,7 +924,7 @@ function dim_apply_pull
 
        cat > $file
 
-       pull_branch=$(sed -e '0,/[gG]it repository at:$/d' $file | head -n 2 | tail -n 1)
+       pull_branch=$(sed -ne '/[gG]it repository at:$/{n;n;p}' $file)
 
        if [[ -z "$pull_branch" ]] ; then
                echoerr "no pull request found"
--

2.17.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 5 lines
Lucas De Marchi
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by
#2 lore raw
Quoted 4 lines · Lucas De Marchi

Now CC the right mailing list. The way dim sets up the repository you can't have individual git configs, e.g. to set a different sendemail.to for dim-tools :(

Quoted 12 lines

Lucas De Marchi

Quoted 8 lines · Lucas De Marchi

A single sed can do the job of taking the second line after a match and it looks simpler.

---

I noticed this while reviewing "[PATCH 2/4] dim: shut up sed broken pipe noise in apply-pull".

Quoted 29 lines
Quoted 24 lines
 dim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dim +1 -2
index 6b684ba5308c..f7cf255db3e1 100755
@@ -924,7 +924,7 @@ function dim_apply_pull
 
        cat > $file
 
-       pull_branch=$(sed -e '0,/[gG]it repository at:$/d' $file | head -n 2 | tail -n 1)
+       pull_branch=$(sed -ne '/[gG]it repository at:$/{n;n;p}' $file)
 
        if [[ -z "$pull_branch" ]] ; then
                echoerr "no pull request found"
--

2.17.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Lucas De Marchi
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 12 lines · Daniel Vetter
Quoted 11 lines · Lucas De Marchi

Now CC the right mailing list. The way dim sets up the repository you can't have individual git configs, e.g. to set a different sendemail.to for dim-tools :(

Lucas De Marchi

Quoted 3 lines · Lucas De Marchi

A single sed can do the job of taking the second line after a match and it looks simpler.

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

---

I noticed this while reviewing "[PATCH 2/4] dim: shut up sed broken pipe noise in apply-pull".

Thanks, pushed.

Quoted 30 lines
Quoted 30 lines
Quoted 25 lines

 dim | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
dim +1 -2
index 6b684ba5308c..f7cf255db3e1 100755
@@ -924,7 +924,7 @@ function dim_apply_pull
 
        cat > $file
 
-       pull_branch=$(sed -e '0,/[gG]it repository at:$/d' $file | head -n 2 | tail -n 1)
+       pull_branch=$(sed -ne '/[gG]it repository at:$/{n;n;p}' $file)
 
        if [[ -z "$pull_branch" ]] ; then
                echoerr "no pull request found"
--

2.17.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Lucas De Marchi
Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx