return error when user break sleep by ctrl-c (#10234)

# Description

Closes: #10218
I think this is `sleep`'s specific issue, it's because it always return
a `Value::nothing` where it's interrupted by `ctrl-c`.

To fix the issue, I'd propose to make it returns Err(ShellError)

This is how it behaves:
```nushell
❯ sleep 5sec; echo "hello!"
^CError: nu:🐚:sleep_breaked

  × Sleep is breaked.

❯ sleep 5sec; ^echo "hello!"
^CError: nu:🐚:sleep_breaked

  × Sleep is breaked.
```
# User-Facing Changes
None

# Tests + Formatting


# After Submitting
This commit is contained in:
WindSoilder 2023-09-05 22:21:30 +08:00 committed by GitHub
parent 5f1e8a6af8
commit 7a728340de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,7 +62,9 @@ impl Command for Sleep {
} }
if nu_utils::ctrl_c::was_pressed(ctrlc_ref) { if nu_utils::ctrl_c::was_pressed(ctrlc_ref) {
break; return Err(ShellError::InterruptedByUser {
span: Some(call.head),
});
} }
} }