Skip to content

Commit 4b59686

Browse files
committed
launch.rs: Remove need for nightly Rust and make subshell error more verbose.
I was assuming [`exit_status_error`][1] would be stabilized quickly, but there's been no movement on it for at least a year and there are now other [(possibly) competing/conflicting proposals][2]. This should reduce [confusion when trying to build the launcher][3]. [1]: rust-lang/rust#84908 [2]: rust-lang/rfcs#3362 [3]: #137 (comment)
1 parent 1948d20 commit 4b59686

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

launch.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
// You should have received a copy of the GNU General Public License
3434
// along with this program. If not, see <http://www.gnu.org/licenses/>.
3535

36-
#![feature(exit_status_error)]
37-
3836
use std::error::Error;
3937
use std::vec::Vec;
4038
use std::collections::hash_map::HashMap;
@@ -175,15 +173,16 @@ fn get_shell_environment() -> Result<HashMap<OsString,OsString>, Box<dyn Error>>
175173

176174
fn osstr(s: &str) -> OsString { OsString::from(s) }
177175
let (mut reader, writer) = pipe()?;
178-
let mut child = Command::new(std::env::var_os("SHELL").unwrap_or(osstr("sh"))).args([osstr("--login"), osstr("-c"), std::env::current_exe()?.into_os_string()])
176+
let mut command = Command::new(std::env::var_os("SHELL").unwrap_or(osstr("sh")));
177+
let mut child = command.args([osstr("--login"), osstr("-c"), std::env::current_exe()?.into_os_string()])
179178
.env(DUMP_ENV_NAME, format!("{}", writer.as_raw_fd()))
180179
.stdin(std::process::Stdio::null())
181180
.spawn()?;
182181
drop(writer); // force parent to close writer
183182
let mut env_raw = Vec::new();
184183
let r2end = reader.read_to_end(&mut env_raw);
185184
let status = child.wait()?; // Make sure we call wait
186-
status.exit_ok()?;
185+
if !status.success() { Err(format!("Command: {command:?}\nFailed: {status}"))? }
187186
let _count = r2end?;
188187

189188
// This dedupes environment variables as a side effect (see comment in dedup_environment())

0 commit comments

Comments
 (0)