Skip to content

Commit

Permalink
Set LANG in spawnutils
Browse files Browse the repository at this point in the history
  • Loading branch information
greymd committed Jan 24, 2024
1 parent 5ef80b2 commit 1ba5bb7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/spawnutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn exec_cmd(
return Ok((Box::new(io::sink()), Box::new(io::empty()), "".to_string()));
}
let child = Command::new(&cmds[0])
.env("LANG", "en_US.UTF-8")
.args(&cmds[1..])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
Expand Down Expand Up @@ -54,6 +55,7 @@ pub fn exec_cmd_sync_replace(input: String, cmds: &Vec<String>, line_end: u8, ch
}
}
let child = Command::new(&cmds_new[0])
.env("LANG", "en_US.UTF-8")
.args(&cmds_new[1..])
.stdout(Stdio::piped())
.spawn()
Expand All @@ -79,6 +81,7 @@ pub fn exec_cmd_sync_replace(input: String, cmds: &Vec<String>, line_end: u8, ch
pub fn exec_cmd_sync(input: String, cmds: &Vec<String>, line_end: u8, chomp: bool) -> String {
debug!("thread: exec_cmd_sync: {:?}", &cmds);
let mut child = Command::new(&cmds[0])
.env("LANG", "en_US.UTF-8")
.args(&cmds[1..])
.stdin(Stdio::piped())
.stdout(Stdio::piped())
Expand Down
1 change: 0 additions & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,6 @@ mod cmdtest {
fn test_csv_double_quotation_utf8() {
let mut cmd = assert_cmd::Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap();
cmd.args(&["--csv", "-f", "2", "--", SED_CMD, "s/./@/g"])
.env("LANG", "en_US.UTF-8")
.write_stdin("名前,\"\"\"\",ノート\n1レコード目,\"\"\"いう\"\"\nえお\",かきく\n2レコード目,\"\"\"さしす\n\"\"せそ\",\"たちつ\nてと\"\n")
.assert()
.stdout("名前,@@@@@@,ノート\n1レコード目,@@@@@@@@\n@@@,かきく\n2レコード目,@@@@@@\n@@@@@,\"たちつ\nてと\"\n");
Expand Down

0 comments on commit 1ba5bb7

Please sign in to comment.