mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 19:47:45 +00:00
fix(install) - Install was failing with '-m 0333'
The parse_numeric was getting ' 0333' as input and showing 'mode is too large ( 0333 > 7777) as error Syntax used: https://sources.debian.org/src/firebird3.0/3.0.7.33374.ds4-1/debian/functions.sh/?hl=145#L145
This commit is contained in:
parent
909acdfeb4
commit
718695d541
3 changed files with 27 additions and 4 deletions
|
@ -146,7 +146,6 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
.help("set permission mode (as in chmod), instead of rwxr-xr-x")
|
.help("set permission mode (as in chmod), instead of rwxr-xr-x")
|
||||||
.value_name("MODE")
|
.value_name("MODE")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.min_values(1)
|
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name(OPT_OWNER)
|
Arg::with_name(OPT_OWNER)
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
pub fn parse_numeric(fperm: u32, mut mode: &str) -> Result<u32, String> {
|
pub fn parse_numeric(fperm: u32, mut mode: &str) -> Result<u32, String> {
|
||||||
let (op, pos) = parse_op(mode, Some('='))?;
|
let (op, pos) = parse_op(mode, Some('='))?;
|
||||||
mode = mode[pos..].trim_start_matches('0');
|
mode = mode[pos..].trim().trim_start_matches('0');
|
||||||
if mode.len() > 4 {
|
if mode.len() > 4 {
|
||||||
Err(format!("mode is too large ({} > 7777)", mode))
|
Err(format!("mode is too large ({} > 7777)", mode))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -102,20 +102,44 @@ fn test_install_component_directories() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_install_mode_numeric() {
|
fn test_install_mode_numeric() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
let dir = "test_install_target_dir_dir_e";
|
let dir = "test_install_target_dir_dir_e";
|
||||||
|
let dir2 = "test_install_target_dir_dir_e2";
|
||||||
|
|
||||||
let file = "test_install_target_dir_file_e";
|
let file = "test_install_target_dir_file_e";
|
||||||
let mode_arg = "--mode=333";
|
let mode_arg = "--mode=333";
|
||||||
|
|
||||||
at.touch(file);
|
at.touch(file);
|
||||||
at.mkdir(dir);
|
at.mkdir(dir);
|
||||||
ucmd.arg(file).arg(dir).arg(mode_arg).succeeds().no_stderr();
|
scene
|
||||||
|
.ucmd()
|
||||||
|
.arg(file)
|
||||||
|
.arg(dir)
|
||||||
|
.arg(mode_arg)
|
||||||
|
.succeeds()
|
||||||
|
.no_stderr();
|
||||||
|
|
||||||
let dest_file = &format!("{}/{}", dir, file);
|
let dest_file = &format!("{}/{}", dir, file);
|
||||||
assert!(at.file_exists(file));
|
assert!(at.file_exists(file));
|
||||||
assert!(at.file_exists(dest_file));
|
assert!(at.file_exists(dest_file));
|
||||||
let permissions = at.metadata(dest_file).permissions();
|
let permissions = at.metadata(dest_file).permissions();
|
||||||
assert_eq!(0o100333 as u32, PermissionsExt::mode(&permissions));
|
assert_eq!(0o100333 as u32, PermissionsExt::mode(&permissions));
|
||||||
|
|
||||||
|
let mode_arg = "-m 0333";
|
||||||
|
at.mkdir(dir2);
|
||||||
|
|
||||||
|
let result = scene.ucmd().arg(mode_arg).arg(file).arg(dir2).run();
|
||||||
|
|
||||||
|
println!("stderr = {:?}", result.stderr);
|
||||||
|
println!("stdout = {:?}", result.stdout);
|
||||||
|
|
||||||
|
assert!(result.success);
|
||||||
|
let dest_file = &format!("{}/{}", dir2, file);
|
||||||
|
assert!(at.file_exists(file));
|
||||||
|
assert!(at.file_exists(dest_file));
|
||||||
|
let permissions = at.metadata(dest_file).permissions();
|
||||||
|
assert_eq!(0o100333 as u32, PermissionsExt::mode(&permissions));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue