Sometimes - perhaps often - you are in situations where you have no control over the shell, in these cases writing "portable" shell scripts is helpful. I have been enjoying "Beginning Portable Shell Scripting"[0] by Peter Seebach for this very reason. [0]https://www.apress.com/us/book/9781430210436
I would like to second this recommendation. I have found "Beginning Portable Shell Scripting" to be invaluable --- and far more comprehensive than I expected given the "Beginning" in the title. I highly recommend it (and the POSIX docs) to anyone who is is interested in portable shell programming.…
……规范)。除了“把手册全背下来”,你根本没办法在别人的机器上测试自己跑的命令到底能不能正常工作。我手头有一整本专门讲这个的书:https://www.amazon.com/Beginning-Portable-Shell-Scripting-Pr... 它梳理了所有的命令、各种常见的 Unix 版本以及哪些 flag 大概率能跑通等等。就连那本书都承认这里面充斥着大量的“民间经验传说”,因为根本没人真跑去一一测试过……
…spec). There's no way to test that the commands you're running will actually work on someone else's machine, other than by "memorizing the manual". I have an entire book on this: https://www.amazon.com/Beginning-Portable-Shell-Scripting-Pr... It goes through all the commands and common versions of Unix and which flags are likely to work, etc. Even that book admits there's a lot of folklore, because nobody has actually gone and tested…
有时候——甚至可以说经常——你会碰到对当前 shell 完全没有控制权的情况,这时候写出“可移植”的 shell 脚本就帮大忙了。正因如此,我最近一直在看 Peter Seebach 写的《Beginning Portable Shell Scripting》[0],感觉非常受用。[0]https://www.apress.com/us/book/9781430210436
Sometimes - perhaps often - you are in situations where you have no control over the shell, in these cases writing "portable" shell scripts is helpful. I have been enjoying "Beginning Portable Shell Scripting"[0] by Peter Seebach for this very reason. [0]https://www.apress.com/us/book/9781430210436
我也想附议推荐这本。我觉得《Beginning Portable Shell Scripting》非常有价值——而且考虑到书名里带有“Beginning”(入门),它的详尽程度其实远超我的预期。我强烈推荐它(以及 POSIX 文档)给所有对可移植 shell 编程感兴趣的人。……
I would like to second this recommendation. I have found "Beginning Portable Shell Scripting" to be invaluable --- and far more comprehensive than I expected given the "Beginning" in the title. I highly recommend it (and the POSIX docs) to anyone who is is interested in portable shell programming.…
……规范)。除了“把手册全背下来”,你根本没办法在别人的机器上测试自己跑的命令到底能不能正常工作。我手头有一整本专门讲这个的书:https://www.amazon.com/Beginning-Portable-Shell-Scripting-Pr... 它梳理了所有的命令、各种常见的 Unix 版本以及哪些 flag 大概率能跑通等等。就连那本书都承认这里面充斥着大量的“民间经验传说”,因为根本没人真跑去一一测试过……
…spec). There's no way to test that the commands you're running will actually work on someone else's machine, other than by "memorizing the manual". I have an entire book on this: https://www.amazon.com/Beginning-Portable-Shell-Scripting-Pr... It goes through all the commands and common versions of Unix and which flags are likely to work, etc. Even that book admits there's a lot of folklore, because nobody has actually gone and tested…