Skip to contentSkip to conversation

kernel-shark: Add quotes around $XDG_SESSION_TYPE in kshark-su-record

PATCH In review Steven Rostedt 2 participants 2 messages Jul 22, 2019 – Jul 23, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel-shark: Add quotes around $XDG_SESSION_TYPE in kshark-su-record

From: "Steven Rostedt (VMware)" <[email protected]>

If XDG_SESSION_TYPE is not set, then $XDG_SESSION_TYPE will become nothing, which means the test:

if [ $XDG_SESSION_TYPE = "wayland" ];

turns into

if [ = "wayland" ];

And will cause a shell error. Adding quotes around "$XDG_SESSION_TYPE" changes an empty $XDG_SESSION_TYPE into:

if [ "" = "wayland" ];

which the shell can understand.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204261

---
 kernel-shark/bin/kshark-su-record | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/bin/kshark-su-record +1 -1
index ee839a26..2477045f 100755
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-if [ $XDG_SESSION_TYPE = "wayland" ]
+if [ "$XDG_SESSION_TYPE" = "wayland" ]
 then
     xhost +si:localuser:root &>/dev/null
 fi
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines · Steven Rostedt

From: "Steven Rostedt (VMware)" <[email protected]>

If XDG_SESSION_TYPE is not set, then $XDG_SESSION_TYPE will become nothing, which means the test:

  if [ $XDG_SESSION_TYPE = "wayland" ];

turns into

  if [  = "wayland" ];

And will cause a shell error. Adding quotes around "$XDG_SESSION_TYPE" changes an empty $XDG_SESSION_TYPE into:

  if [ "" = "wayland" ];

which the shell can understand.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=204261

---
  kernel-shark/bin/kshark-su-record | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel-shark/bin/kshark-su-record +0 -0
index ee839a26..2477045f 100755

kernel-shark/bin/kshark-su-record line 6

Quoted 7 lines
kernel-shark/bin/kshark-su-record +1 -1
@@ -1,6 +1,6 @@
  #!/bin/bash
 
-if [ $XDG_SESSION_TYPE = "wayland" ]
+if [ "$XDG_SESSION_TYPE" = "wayland" ]
  then
      xhost +si:localuser:root &>/dev/null
  fi

Thanks!