Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added `maybe`.

  I didn't write this, but the copyright is intact.

  I updated the code to run with warnings/strictness, although it
 is so minimal I needn't have bothered.
  • Loading branch information...
commit c98db2b18416444d7de21ef409ef17a03450cc56 1 parent 4b3e989
Steve Kemp authored
Showing with 61 additions and 0 deletions.
  1. +17 −0 README.md
  2. +44 −0 maybe
17 README.md
View
@@ -16,6 +16,23 @@ Example:
+maybe
+-----
+
+In a similar vain to `true` and `false` the `maybe` command exits with
+a status code of zero or one, depending on a random number.
+
+It can be useful in scripts which need to test-failures, or which benefit
+from randomness:
+
+Example:
+
+ maybe && echo "I pass"
+
+ maybe || echo "I fail"
+
+
+
multi-ping
----------
44 maybe
View
@@ -0,0 +1,44 @@
+#!/usr/bin/perl -w
+#
+# maybe - companion to /usr/bin/true and /usr/bin/false.
+#
+# This should be installed in your system location, eg /usr/bin/maybe.
+#
+# 08-Nov-2004 ver 1.00
+#
+# USAGE: maybe
+#
+# COPYRIGHT: Copyright (c) 2004 Brendan Gregg.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# (http://www.gnu.org/copyleft/gpl.html)
+#
+# 08-Nov-2004 Brendan Gregg Created this.
+
+use strict;
+use warnings;
+
+#
+# Generate Value
+#
+my $maybe = rand(1);
+$maybe = sprintf( "%.0f", $maybe ); # see "perldoc -q round"
+
+#
+# Return Value
+#
+exit($maybe);
+
Please sign in to comment.
Something went wrong with that request. Please try again.