简体   繁体   中英

How to remove trailing newline from command arguments in fish?

As far as I know, in fish as well as in many other command lines, the return statement is reserved for success/failure codes, and the standard way to 'return a string' is to echo the result like this:

function format-commit-message
    echo e2e-new: $argv[1]
    echo
    echo "Jira: APP-1234"
end

However, this means that all such strings end with a newline character. I tried to remove it because that is the commit message policy:

git commit -m ( format-commit-message "new commit" | string split0 | strig sub -e -1 )

But the result is:

fatal: empty string is not a valid pathspec. please use. instead if you meant to match all paths

Could you tell me what I am doing wrong?

Use echo 's -n parameter to omit the newline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM