diff options
author | Niklas Claesson <nicke.claesson@gmail.com> | 2017-01-23 20:10:26 +0100 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-01-25 08:50:28 -0800 |
commit | 04c5ad372a90ed26bbe6f79e723aba7d31329fc9 (patch) | |
tree | c3af39774b32a56e3206ffe6b22560181cf8ebfe /src/tty.rs | |
parent | 1dca5617e2c308b3c2f86d6cfa9d530d8d178885 (diff) | |
download | alacritty-04c5ad372a90ed26bbe6f79e723aba7d31329fc9.tar.gz alacritty-04c5ad372a90ed26bbe6f79e723aba7d31329fc9.zip |
Implement argument passing in config
This commit implements the following syntax in the config file:
```yaml
shell:
program: /bin/bash
args:
- --login
- --norc
```
Diffstat (limited to 'src/tty.rs')
-rw-r--r-- | src/tty.rs | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -19,13 +19,13 @@ use std::fs::File; use std::os::unix::io::FromRawFd; use std::os::unix::process::CommandExt; use std::ptr; -use std::process; +use std::process::{Command, Stdio}; use libc::{self, winsize, c_int, pid_t, WNOHANG, WIFEXITED, WEXITSTATUS, SIGCHLD, TIOCSCTTY}; use term::SizeInfo; use display::OnResize; -use config::Config; +use config::{Config, Shell}; /// Process ID of child process /// @@ -186,19 +186,23 @@ pub fn new<T: ToWinsize>(config: &Config, size: T) -> Pty { let (master, slave) = openpty(win.ws_row as _, win.ws_col as _); - let shell = config.shell().unwrap_or(pw.shell); + let default_shell = Shell::new(pw.shell); + let shell = config.shell().unwrap_or(&default_shell); - let mut builder = process::Command::new(shell); + let mut builder = Command::new(shell.program()); + for arg in shell.args() { + builder.arg(arg); + } // Setup child stdin/stdout/stderr as slave fd of pty - builder.stdin(unsafe { process::Stdio::from_raw_fd(slave) }); - builder.stderr(unsafe { process::Stdio::from_raw_fd(slave) }); - builder.stdout(unsafe { process::Stdio::from_raw_fd(slave) }); + builder.stdin(unsafe { Stdio::from_raw_fd(slave) }); + builder.stderr(unsafe { Stdio::from_raw_fd(slave) }); + builder.stdout(unsafe { Stdio::from_raw_fd(slave) }); // Setup environment builder.env("LOGNAME", pw.name); builder.env("USER", pw.name); - builder.env("SHELL", shell); + builder.env("SHELL", shell.program()); builder.env("HOME", pw.dir); builder.env("TERM", "xterm-256color"); // sigh |