Skip to content

Commit a86cfd4

Browse files
authored
Merge branch 'main' into sort_sort-h-thousands-sep.sh
2 parents cfbcf7e + cbbff30 commit a86cfd4

File tree

7 files changed

+58
-3
lines changed

7 files changed

+58
-3
lines changed

.github/workflows/android.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
ram: [4096]
4040
api-level: [28]
4141
target: [google_apis_playstore]
42-
arch: [x86, x86_64] # , arm64-v8a
42+
arch: [x86_64] # ,x86 ,arm64-v8a
4343
runs-on: ${{ matrix.os }}
4444
env:
4545
EMULATOR_RAM_SIZE: ${{ matrix.ram }}

src/uu/mkfifo/locales/en-US.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ mkfifo-error-invalid-mode = invalid mode: { $error }
1111
mkfifo-error-missing-operand = missing operand
1212
mkfifo-error-cannot-create-fifo = cannot create fifo { $path }: File exists
1313
mkfifo-error-cannot-set-permissions = cannot set permissions on { $path }: { $error }
14+
mkfifo-error-non-file-permission = mode must specify only file permission bits

src/uu/mkfifo/locales/fr-FR.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ mkfifo-error-invalid-mode = mode invalide : { $error }
1111
mkfifo-error-missing-operand = opérande manquant
1212
mkfifo-error-cannot-create-fifo = impossible de créer le fifo { $path } : Le fichier existe
1313
mkfifo-error-cannot-set-permissions = impossible de définir les permissions sur { $path } : { $error }
14+
mkfifo-error-non-file-permission = le mode ne doit spécifier que des bits de permission de fichier

src/uu/mkfifo/src/mkfifo.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2828
let mode = calculate_mode(matches.get_one::<String>(options::MODE))
2929
.map_err(|e| USimpleError::new(1, translate!("mkfifo-error-invalid-mode", "error" => e)))?;
3030

31+
// Check if mode contains special bits
32+
let non_file_permission_bits = 0o7000; // setuid, setgid, sticky bits
33+
if mode & non_file_permission_bits != 0 {
34+
return Err(USimpleError::new(
35+
1,
36+
translate!("mkfifo-error-non-file-permission"),
37+
));
38+
}
39+
3140
let fifos: Vec<String> = match matches.get_many::<String>(options::FIFO) {
3241
Some(v) => v.cloned().collect(),
3342
None => {

src/uu/unexpand/src/unexpand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ fn next_tabstop(tab_config: &TabConfig, col: usize) -> Option<usize> {
303303
}
304304

305305
if tabstops.len() == 1
306-
&& tab_config.increment_size.is_none()
307-
&& tab_config.extend_size.is_none()
306+
&& !matches!(tab_config.increment_size, Some(n) if n > 0)
307+
&& !matches!(tab_config.extend_size, Some(n) if n > 0)
308308
{
309309
// Simple case: single tab stop, repeat at that interval
310310
Some(tabstops[0] - col % tabstops[0])

tests/by-util/test_mkfifo.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,22 @@ fn test_create_one_fifo_with_invalid_mode() {
4343
.stderr_contains("invalid mode");
4444
}
4545

46+
#[test]
47+
fn test_create_one_fifo_with_non_file_permission_mode() {
48+
new_ucmd!()
49+
.arg("abcd")
50+
.arg("-m")
51+
.arg("1777")
52+
.fails()
53+
.stderr_is("mkfifo: mode must specify only file permission bits\n");
54+
new_ucmd!()
55+
.arg("abcd")
56+
.arg("-m")
57+
.arg("1999")
58+
.fails()
59+
.stderr_contains("invalid mode");
60+
}
61+
4662
#[test]
4763
fn test_create_multiple_fifos() {
4864
new_ucmd!()

tests/by-util/test_unexpand.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,31 @@ fn test_blanks_ext2() {
329329
.succeeds()
330330
.stdout_is("\t\t");
331331
}
332+
333+
#[test]
334+
fn test_extended_tabstop_syntax() {
335+
let test_cases = [
336+
// Standalone /N: tabs at multiples of N
337+
("-t /9", " ", "\t"), // 9 spaces -> 1 tab
338+
("-t /9", " ", "\t\t"), // 18 spaces -> 2 tabs
339+
// Standalone +N: tabs at multiples of N
340+
("-t +6", " ", "\t"), // 6 spaces -> 1 tab
341+
("-t +6", " ", "\t\t"), // 12 spaces -> 2 tabs
342+
// 3,/0 and 3,+0 should behave like just 3
343+
("-t 3,/0", " ", "\t\t\t "), // 10 spaces -> 3 tabs + 1 space
344+
("-t 3,+0", " ", "\t\t\t "), // 10 spaces -> 3 tabs + 1 space
345+
("-t 3", " ", "\t\t\t "), // 10 spaces -> 3 tabs + 1 space
346+
// 3,/0 with text
347+
("-t 3,/0", " test", "\ttest"), // 3 spaces + text -> 1 tab + text
348+
// 3,+6 means tab stops at 3, 9, 15, 21, ...
349+
("-t 3,+6", " ", "\t\t\t "), // 20 spaces -> 3 tabs + 5 spaces
350+
];
351+
352+
for (args, input, expected) in test_cases {
353+
new_ucmd!()
354+
.args(&args.split_whitespace().collect::<Vec<_>>())
355+
.pipe_in(input)
356+
.succeeds()
357+
.stdout_is(expected);
358+
}
359+
}

0 commit comments

Comments
 (0)