From 25bfebc2f18d35e78a2f3dc01e4eee8aae0c2b09 Mon Sep 17 00:00:00 2001
From: Simon Rose <simon.rose@ess.eu>
Date: Thu, 14 Dec 2023 16:26:15 +0100
Subject: [PATCH] Remove 'inappropriate ioctl for device' warning

This only came up if I ran, for example
```
$ echo exit | iocsh
```

See https://unix.stackexchange.com/a/26782/445931. This assume bash,
which is safe, and fixes the issue.
---
 require-ess/tools/iocsh_utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/require-ess/tools/iocsh_utils.py b/require-ess/tools/iocsh_utils.py
index 19c11c7b..e94d7633 100755
--- a/require-ess/tools/iocsh_utils.py
+++ b/require-ess/tools/iocsh_utils.py
@@ -12,7 +12,7 @@ from pathlib import Path
 @atexit.register
 def graceful_shutdown() -> None:
     print("\nExiting e3 IOC shell")
-    os.system("stty sane")
+    os.system("[[ $- == *i* ]] && stty sane")
 
 
 class TemporaryStartupScript:
-- 
GitLab