Skip to content

Commit 10750f4

Browse files
committed
uniq: use helper function for file creation
1 parent e4c7b71 commit 10750f4

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/uu/uniq/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ path = "src/uniq.rs"
2020

2121
[dependencies]
2222
clap = { workspace = true }
23-
uucore = { workspace = true, features = ["parser"] }
23+
uucore = { workspace = true, features = ["parser", "fs"] }
2424
fluent = { workspace = true }
2525

2626
[dev-dependencies]

src/uu/uniq/src/uniq.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use std::num::IntErrorKind;
1414
use uucore::display::Quotable;
1515
use uucore::error::{FromIo, UError, UResult, USimpleError};
1616
use uucore::format_usage;
17+
use uucore::fs::create_file_restrictive_perm;
1718
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
1819
use uucore::posix::{OBSOLETE, posix_version};
1920
use uucore::translate;
@@ -824,7 +825,7 @@ fn open_input_file(in_file_name: Option<&OsStr>) -> UResult<Box<dyn BufRead>> {
824825
fn open_output_file(out_file_name: Option<&OsStr>) -> UResult<Box<dyn Write>> {
825826
Ok(match out_file_name {
826827
Some(path) if path != "-" => {
827-
let out_file = File::create(path).map_err_context(
828+
let out_file = create_file_restrictive_perm(path, true).map_err_context(
828829
|| translate!("uniq-error-could-not-open", "path" => path.maybe_quote()),
829830
)?;
830831
Box::new(BufWriter::with_capacity(OUTPUT_BUFFER_CAPACITY, out_file))

0 commit comments

Comments
 (0)