Skip to content

Commit

Permalink
fix(MusicCommand): trim stdin input to remove trailing spaces
Browse files Browse the repository at this point in the history
- Change `rtrim` to `trim` for stdin input to remove both leading and trailing spaces.
- Close the stdin stream after reading to prevent resource leaks.
- Ensure consistent handling of input regardless of whitespace.
  • Loading branch information
guanguans committed Oct 14, 2024
1 parent 6dbe893 commit b6933c2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/Commands/MusicCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ public function handle(): void
->when(windows_os(), static fn () => warning(__('windows_hint')))
->tap(static function () use (&$stdinKeyword): void {
if (($fstat = fstat(\STDIN)) && 0 < $fstat['size']) {
$stdinKeyword = rtrim(stream_get_contents(\STDIN));
$stdinKeyword = trim(stream_get_contents(\STDIN));
fclose(\STDIN);
}

// fclose(\STDIN);
})
->tap(function () use (&$keyword, $stdinKeyword): void {
$keyword = str($stdinKeyword ?: $this->argument('keyword') ?? text(
Expand Down

0 comments on commit b6933c2

Please sign in to comment.