Skip to content
This repository was archived by the owner on Mar 30, 2020. It is now read-only.

Commit 86267de

Browse files
author
KrustyHack
committed
Adding until-error and updating README.md
1 parent 6ed9338 commit 86267de

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,24 @@ Alternatives:
392392
* `until-success ping -c 1 1.2.3.4; ssh user@1.2.3.4`
393393

394394

395+
396+
until-error
397+
-------------
398+
399+
Repeat the specific command until it fails - run at least once
400+
always.
401+
402+
Example:
403+
404+
./until-error ssh example.com -l root -i ~/.ssh/example.com.key
405+
406+
Trivial (ba)sh alternatives:
407+
408+
* while true ; do $cmd; done
409+
* watch -n 2 $cmd
410+
411+
412+
395413
when-down
396414
-------
397415

@@ -403,6 +421,10 @@ Example:
403421
Waiting for 1.2.3.4 to get down...
404422
down
405423

424+
Alternatives:
425+
426+
* `until-error ping -c 1 -W 1 1.2.3.4; echo "down"`
427+
406428

407429

408430
which-shell

until-error

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
#
3+
# About
4+
# -----
5+
# Repeat the command until it fails
6+
#
7+
8+
"$@"
9+
10+
#
11+
# If the status code was zero then repeat.
12+
#
13+
while [ $? -eq 0 ]; do
14+
"$@"
15+
done
16+
17+

0 commit comments

Comments
 (0)