Re: [ovs-dev] [PATCH] utilities/bashcomp: Fix PS1 generation on new bash

2023-05-26 Thread 0-day Robot
Bleep bloop.  Greetings Timothy Redaelli, I am a robot and I have tried out 
your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Line is 89 characters long (recommended limit is 79)
#31 FILE: utilities/ovs-appctl-bashcomp.bash:227:
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 
4))); then

WARNING: Line is 89 characters long (recommended limit is 79)
#48 FILE: utilities/ovs-vsctl-bashcomp.bash:417:
if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 
4))); then

Lines checked: 59, Warnings: 2, Errors: 0


Please check this out.  If you feel there has been an error, please email 
acon...@redhat.com

Thanks,
0-day Robot
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] utilities/bashcomp: Fix PS1 generation on new bash

2023-05-26 Thread Timothy Redaelli
The current implementation used to extract PS1 prompt for ovs-vsctl is
broken on recent Bash releases.
Starting from Bash 4.4 it's possible to use @P expansion in order to get
the quoted PS1 directly.

This commit makes the 2 bash completion files to use @P expansion in order
to get the quoted PS1 on Bash >= 4.4.

Reported-at: https://bugzilla.redhat.com/2170344
Reported-by: Martin Necas 
Signed-off-by: Timothy Redaelli 
---
 utilities/ovs-appctl-bashcomp.bash | 6 ++
 utilities/ovs-vsctl-bashcomp.bash  | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/utilities/ovs-appctl-bashcomp.bash 
b/utilities/ovs-appctl-bashcomp.bash
index 4384be8ae..dc5a9c7b4 100644
--- a/utilities/ovs-appctl-bashcomp.bash
+++ b/utilities/ovs-appctl-bashcomp.bash
@@ -223,6 +223,12 @@ printf_stderr() {
 # The code below is taken from Peter Amidon.  His change makes it more
 # robust.
 extract_bash_prompt() {
+# On Bash 4.4+ just use the @P expansion
+if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 
4))); then
+_BASH_PROMPT="${PS1@P}"
+return
+fi
+
 local myPS1 v
 
 myPS1="$(sed 's/Begin prompt/\\Begin prompt/; s/End prompt/\\End prompt/' 
<<< "$PS1")"
diff --git a/utilities/ovs-vsctl-bashcomp.bash 
b/utilities/ovs-vsctl-bashcomp.bash
index fc8245bfb..6d7e1912d 100644
--- a/utilities/ovs-vsctl-bashcomp.bash
+++ b/utilities/ovs-vsctl-bashcomp.bash
@@ -413,6 +413,12 @@ _ovs_vsctl_get_PS1 () {
 return;
 fi
 
+# On Bash 4.4+ just use the @P expansion
+if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 
4))); then
+printf '%s\n' "${PS1@P}"
+return
+fi
+
 # Original inspiration from
 # http://stackoverflow.com/questions/10060500/bash-how-to-evaluate-ps1-ps2,
 # but changed quite a lot to make it more robust.
-- 
2.40.1

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev