An alternative is toSince version 3.4.0 (released in March 2022), you can do instead:
set output (cmd | string collect --allow-empty --no-trim-newlines)
 With older versions, you could do:
 Since versionWith the caveat that $output is an empty list instead of a list with one empty element if there's no output.
 Version 3.4.0 (released in March 2022), fish also supportsadded support for $(...) which behaves like (...) except that it can also be used inside double quotes in which case it behaves like in the POSIX shell: the output is not split on lines but all trailing newline characters are removed.