aboutsummaryrefslogtreecommitdiff
path: root/src/hooks.py
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-10-06 17:06:30 +0200
committerCharles Cabergs <me@cacharle.xyz>2020-10-06 17:06:30 +0200
commit058491e35baa8bc73e14b48ceb765a3fe3c07e1f (patch)
tree26b44b71ea12cb6cd825783d2ddebe0902c4999a /src/hooks.py
parent1e713de9e5013c91495e0428179947f0764409a8 (diff)
downloadminishell_test-058491e35baa8bc73e14b48ceb765a3fe3c07e1f.tar.gz
minishell_test-058491e35baa8bc73e14b48ceb765a3fe3c07e1f.tar.bz2
minishell_test-058491e35baa8bc73e14b48ceb765a3fe3c07e1f.zip
Added variable terminal size
Diffstat (limited to 'src/hooks.py')
-rw-r--r--src/hooks.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/hooks.py b/src/hooks.py
index 1e01712..01319d1 100644
--- a/src/hooks.py
+++ b/src/hooks.py
@@ -6,11 +6,13 @@
# By: charles <me@cacharle.xyz> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2020/09/11 16:10:20 by charles #+# #+# #
-# Updated: 2020/09/17 11:06:52 by charles ### ########.fr #
+# Updated: 2020/10/06 09:12:52 by cacharle ### ########.fr #
# #
# ############################################################################ #
import re
+import os
+import sys
import config
@@ -53,3 +55,17 @@ def replace_double_slash(output):
def replace_double_semi_colon(output):
"""Replace occurence of double semi-colon by one"""
return output.replace(";;", ";")
+
+
+def platform_exit_status(darwin_status, linux_status, windows_status=None):
+ def hook(status):
+ name = os.uname().sysname
+ if name == "Darwin":
+ return status
+ elif name == "Linux":
+ return (darwin_status if status == linux_status else status)
+ else:
+ raise RuntimeError("This platform exit codes are not supported yet,"
+ "feel free to contact me to add it.")
+ sys.exit(2)
+ return status