]> Dogcows Code - chaz/p5-File-KDBX/blobdiff - t/files/bin/ykinfo
Fix YubiKey unit test portability issues
[chaz/p5-File-KDBX] / t / files / bin / ykinfo
index 8a93cc3b208d2c7cd555b67a0afbdb5141af7fe6..a8cc0218e0d273ff314e2dc7f47475e0e166e394 100755 (executable)
@@ -1,43 +1,37 @@
-#!/bin/sh
+#!/usr/bin/env perl
 
 # This is a fake ykinfo program that provides canned responses, for testing.
 
-device=
-all=
+use warnings;
+use strict;
 
-while getopts an: arg
-do
-    case "$arg" in
-        n)
-            device="$OPTARG"
-            ;;
-        a)
-            all=1
-            ;;
-    esac
-done
+use Getopt::Std;
 
-case "$device" in
-    0)
-        printf 'serial: 123
+our ($opt_a, $opt_n);
+getopts('an:');
+
+my $device = $opt_n // -1;
+
+if ($device == 0) {
+    print q{serial: 123
 version: 2.0.0
 touch_level: 0
 vendor_id: 1050
 product_id: 113
-'
-        exit 0
-        ;;
-    1)
-        printf 'serial: 456
+};
+    exit 0;
+}
+elsif ($device == 1) {
+    print q{serial: 456
 version: 3.0.1
 touch_level: 10
 vendor_id: 1050
 product_id: 401
-'
-        exit 0
-        ;;
-    *)
-        echo "Yubikey core error: no yubikey present" >&2
-        exit 1
-esac
+};
+    exit 0;
+}
+else {
+    print STDERR "Yubikey core error: no yubikey present\n";
+    exit 1;
+}
 
This page took 0.022368 seconds and 4 git commands to generate.