Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
FatGhosta
V2EX  ›  Linux

什么样的 shell 脚本可以称为写得好的脚本?

  •  3
     
  •   FatGhosta · Jul 21, 2015 · 4713 views
    This topic created in 3947 days ago, the information mentioned may be changed or developed.
    13 replies    2015-07-30 22:41:12 +08:00
    echo1937
        1
    echo1937  
       Jul 21, 2015
    写1个shell脚本的时间,可以写3个py脚本,一个2.6.6, 一个2.7.5,一个3.4.3


    正经回答,稍微大点的shell脚本写着实在是费劲。
    VmuTargh
        2
    VmuTargh  
       Jul 21, 2015
    Netbeans
    chuxiwen
        3
    chuxiwen  
       Jul 21, 2015 via iPad   ❤️ 3
    都 shell 了。能用就行吧。如果要垮平台用的话,尽量做到 bourne shell compatible 吧。最后祝你好运。

    下边是 google 的 guildline
    https://google-styleguide.googlecode.com/svn/trunk/shell.xml
    frankzeng
        4
    frankzeng  
       Jul 21, 2015
    简单一点还行,复杂逻辑的用shell不太合适。
    Dongdong36
        5
    Dongdong36  
       Jul 21, 2015
    写注释 写注释 写注释
    staticor
        6
    staticor  
       Jul 21, 2015
    comment, log.
    neo2015
        7
    neo2015  
       Jul 22, 2015
    当年被迫在openwrt写shell cgi,感觉心好累
    bramblex
        8
    bramblex  
       Jul 22, 2015
    楼上写python的跟我把下面这行shellscript用python实现下

    echo `who | awk '{print $1}' | sort | uniq` | sed 's/ /, /g' > file.txt

    shellscript最强大的功能是组合连接各个命令行工具,你完全可以增加命令行工具来配合shellscript编写。如果你觉得shellscript非常麻烦,那么说明你肯定用错了场景。比如你要拿shellscript做大量运算,那绝对是坑爹的……
    bramblex
        9
    bramblex  
       Jul 22, 2015
    同时,即便是shellscript,也是可以进行良好的模块化的。shellscript真正能写的人其实不是很多,大部分说自己会写shellscript的都只是会逐行罗列几个命令而已
    FatGhosta
        10
    FatGhosta  
    OP
       Jul 22, 2015
    julyclyde
        11
    julyclyde  
       Jul 22, 2015
    换到另一个发行版的白板机器还能直接运行无需修改的,就是好脚本
    jack139
        12
    jack139  
       Jul 23, 2015
    除了系统管理脚本,不建议用shell,python是个不错的选择
    lilydjwg
        13
    lilydjwg  
       Jul 30, 2015
    @julyclyde 这样的脚本恐怕除了 configure 之外很少见呢。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5683 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 737ms · UTC 07:57 · PVG 15:57 · LAX 00:57 · JFK 03:57
    ♥ Do have faith in what you're doing.