如何使用entr编译并运行Rust文件?

问题描述 投票:1回答:1

如何在每次保存时使用entr自动编译并运行测试Rust文件?我试过了

ls test.rs | entr -c "rustc test.rs && ./test"

但它给出了错误:

entr: exec rustc test.rs && ./test: No such file or directory
shell rust
1个回答
2
投票

你需要-s参数,它使用你的shell来评估命令:

-s  Evaluate the first argument using the
    interpreter specified by the SHELL
    environment variable.  When this flag
    is set, the name of the shell and exit
    code is printed after each invocation.

正确的命令是:

ls test.rs | entr -cs "rustc test.rs && ./test"

作为奖励,它还会打印每个调用的退出代码!

Hello World!
zsh returned exit code 0
© www.soinside.com 2019 - 2024. All rights reserved.