From e2b25049df9a4da28168b7378016f1650d0dfa6b Mon Sep 17 00:00:00 2001 From: Alexander GQ Gerasiov Date: Wed, 24 Oct 2018 12:47:07 +0300 Subject: [PATCH 1/1] ppsfind: Use /bin/sh, fix possible issues. Signed-off-by: Alexander GQ Gerasiov --- ppsfind | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/ppsfind b/ppsfind index 2ff7abc..adbcab9 100644 --- a/ppsfind +++ b/ppsfind @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # ppsfind -- find pps device by name # # Copyright (C) 2005-2007 Rodolfo Giometti @@ -15,16 +15,14 @@ SYS="/sys/class/pps/" -if [ $# -lt 1 ] ; then +if [ $# -ne 1 ] ; then echo "usage: ppsfind " >&2 exit 1 fi -for d in $(ls $SYS) ; do - if grep $1 $SYS/$d/name >& /dev/null || \ - grep $1 $SYS/$d/path >& /dev/null ; then - echo "$d: name=$(cat $SYS/$d/name) path=$(cat $SYS/$d/path)" - fi +for dev in $SYS/* ; do + grep -q "$1" "$dev/name" || grep -q "$1" "$dev/path" && \ + echo "$(basename "$dev"): name=$(cat $dev/name) path=$(cat $dev/path)" done exit 0 -- 2.30.0