mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +00:00
truncate: Clamp file size to 0 when using the -s
option
When using the `-s` option to reduce the size of a file, the file size is now set to zero if the argument given would result in a file size less than zero. This matches the behavior of truncate on Linux and FreeBSD.
This commit is contained in:
parent
8e79afebb9
commit
ea411774f0
1 changed files with 1 additions and 1 deletions
|
@ -99,7 +99,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
size = stat.st_size + size;
|
||||
break;
|
||||
case OP_Shrink:
|
||||
size = stat.st_size - size;
|
||||
size = max(stat.st_size - size, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue