dd: error with invalid size suffixes, add 'm'
When invoking with dd with an invalid size suffix, we silently accept the suffix. This can lead to confusion, because lines like: dd -bs 1K dd -bs 1m will silently copy in 1-byte increments. This has caught people by surprise. While we're at it, megabytes are convenient, so let's have them too.
This commit is contained in:
parent
67c15c1e47
commit
cb7ba0e640
1 changed files with 6 additions and 1 deletions
|
@ -353,7 +353,9 @@ number(vlong big)
|
|||
n = n*10 + *cs++ - '0';
|
||||
for(;;)
|
||||
switch(*cs++) {
|
||||
|
||||
case 'm':
|
||||
n *= 1024*1024;
|
||||
continue;
|
||||
case 'k':
|
||||
n *= 1024;
|
||||
continue;
|
||||
|
@ -373,6 +375,9 @@ number(vlong big)
|
|||
exits("range");
|
||||
}
|
||||
return n;
|
||||
default:
|
||||
fprint(2, "dd: invalid size suffix '%c'\n", cs[-1]);
|
||||
exits("invalid");
|
||||
}
|
||||
/* never gets here */
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue