git.delta.rocks / jrsonnet / refs/commits / f5a8281dad2c

difftreelog

source

cmds/fleet/src/extra_args.rs480 Bsourcehistory
1use std::ffi::{OsStr, OsString};23use anyhow::{Result, anyhow};45pub fn parse_os(os: &OsStr) -> Result<Vec<OsString>> {6	Ok(shlex::bytes::split(os.as_encoded_bytes())7		.ok_or_else(|| anyhow!("invalid arguments"))?8		.into_iter()9		.map(|a| {10			// Unpaired surrogates are not touched11			unsafe { OsString::from_encoded_bytes_unchecked(a) }12		})13		.collect())14}15// pub fn parse(s: &str) -> Result<Vec<OsString>> {16// 	let osstr = OsString::try_from(s)?;17// 	parse_os(&osstr)18// }