In Bash, how to add “Are you sure [Y/n]” to any command or alias?

前端 未结 17 2954
轮回少年
轮回少年 2020-11-29 15:11

In this particular case, I\'d like to add a confirm in Bash for

Are you sure? [Y/n]

for Mercurial\'s hg push ssh://username@www.example.com//some

17条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-29 15:12

    This isn't exactly an "asking for yes or no" but just a hack: alias the hg push ... not to hgpushrepo but to hgpushrepoconfirmedpush and by the time I can spell out the whole thing, the left brain has made a logical choice.

提交回复
热议问题