Change in osmo-dev[master]: find the terminal once and abort if missing

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Wed Oct 24 10:49:41 UTC 2018


osmith has submitted this change and it was merged. ( https://gerrit.osmocom.org/11143 )

Change subject: find the terminal once and abort if missing
......................................................................

find the terminal once and abort if missing

Change-Id: Ie823e17ff1e7ad3ba23998233b41a810c90858b3
---
M net/tmpl_std/run.sh
1 file changed, 16 insertions(+), 4 deletions(-)

Approvals:
  Neels Hofmeyr: Looks good to me, approved
  osmith: Verified



diff --git a/net/tmpl_std/run.sh b/net/tmpl_std/run.sh
index 57dcc23..cca7a75 100755
--- a/net/tmpl_std/run.sh
+++ b/net/tmpl_std/run.sh
@@ -34,18 +34,30 @@
 logdir="current_log"
 mkdir -p "$logdir"
 
+find_term() {
+  # Find a terminal program and write to the global "terminal" variable
+  local programs="urxvt xterm"
+  local program
+  for program in $programs; do
+    terminal="$(which $program)"
+    [ -n "$terminal" ] && return
+  done
+
+  # No terminal found
+  echo "ERROR: Couldn't find terminal program! Looked for: $programs"
+  exit 1
+}
+
 term() {
   title="$2"
   if [ -z "$title" ]; then
     title="$(basename $@)"
   fi
-  terminal="$(which urxvt || which xterm)"
-  if ! which $terminal; then
-    echo "CANNOT FIND XTERM PROGRAM"
-  fi
   exec $terminal -title "CN:$title" -e sh -c "export LD_LIBRARY_PATH='/usr/local/lib'; $1; echo; while true; do echo 'q Enter to close'; read q_to_close; if [ \"x\$q_to_close\" = xq ]; then break; fi; done"
 }
 
+find_term
+
 sudo tcpdump -i $dev -n -w current_log/$dev.single.pcap -U not port 22 &
 sudo tcpdump -i lo -n -w current_log/lo.single.pcap -U not port 22 &
 

-- 
To view, visit https://gerrit.osmocom.org/11143
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-dev
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie823e17ff1e7ad3ba23998233b41a810c90858b3
Gerrit-Change-Number: 11143
Gerrit-PatchSet: 6
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Assignee: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181024/b3ad0fa6/attachment.htm>


More information about the gerrit-log mailing list