xargs with command that open editor leaves shell in weird state

前端 未结 5 880
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 04:27

I tried to make an alias for committing several different git projects. I tried something like

cat projectPaths | \\
xargs -I project git --git-dir=project/.gi         


        
5条回答
  •  温柔的废话
    2021-02-04 05:01

    The man page for GNU xargs shows a similar command for emacs:

    xargs sh -c 'emacs "$@" < /dev/tty' emacs
    

    (in this command, the second "emacs" is the "dummy string" that wisbucky refers to in a comment to this answer)

    and says this:

       Launches  the  minimum  number of copies of Emacs needed, one after the
       other, to edit the files listed on xargs' standard input.  This example
       achieves the same effect as BSD's -o option, but in a more flexible and
       portable way.
    

    Another thing to try is using -a instead of cat:

    xargs -a projectPaths -I project git --git-dir=project/.git --work-tree=project commit -a
    

    or some combination of the two.

提交回复
热议问题