How to conditionally add flags to shell scripts?

后端 未结 3 1710
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-19 08:14

I want to run a command inside my bash script with or without a -v flag depending on if the environment variable $VERBOSE is defined. Something like this:



        
3条回答
  •  攒了一身酷
    2021-02-19 08:39

    This seems to work:

    composer dump-autoload $([ "$env" = "production" ] && printf '--classmap-authoritative')
    

提交回复
热议问题