aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/terminal.vala
diff options
context:
space:
mode:
authorWolfgang Müller2019-10-07 20:14:33 +0200
committerWolfgang Müller2019-10-07 20:14:33 +0200
commitf3fad3de0863ed0571b884980132f8e80612776f (patch)
treed35cf3862ee6c484a775a52061369ee6becd7ff5 /terminal.vala
parent086c71c87b95372c8a8bf4ff98cf77f93fe6b569 (diff)
downloadweltschmerz-f3fad3de0863ed0571b884980132f8e80612776f.tar.gz
Introduce fallbacks when getting the user's shell
Diffstat (limited to 'terminal.vala')
-rw-r--r--terminal.vala16
1 files changed, 15 insertions, 1 deletions
diff --git a/terminal.vala b/terminal.vala
index c6c2525..a7cfb6b 100644
--- a/terminal.vala
+++ b/terminal.vala
@@ -71,7 +71,7 @@ class Terminal : Gtk.Overlay {
var argv = args[1:args.length];
if (argv.length == 0) {
- argv = { Environment.get_variable("SHELL") };
+ argv = { get_shell() };
}
vte.spawn_sync(DEFAULT, null, argv, null, SEARCH_PATH, null, null, null);
@@ -145,6 +145,20 @@ class Terminal : Gtk.Overlay {
}
}
+ string get_shell() {
+ var env_shell = Environment.get_variable("SHELL");
+ if (env_shell != null && env_shell.length > 0){
+ return env_shell;
+ }
+
+ unowned Posix.Passwd pw = Posix.getpwuid(Posix.getuid());
+ if (pw != null && pw.pw_shell.length > 0) {
+ return pw.pw_shell;
+ }
+
+ return "/bin/sh";
+ }
+
bool match_modifiers(int state, Gdk.ModifierType modifiers) {
return (state & modifiers) == modifiers;
}