!15 [sync] PR-13: ppsfind: Use /bin/sh, fix possible issues.

From: @openeuler-sync-bot 
Reviewed-by: @wu-leilei 
Signed-off-by: @wu-leilei
This commit is contained in:
openeuler-ci-bot 2024-01-02 09:56:23 +00:00 committed by Gitee
commit 00db49f502
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 50 additions and 1 deletions

View File

@ -1,12 +1,14 @@
Name: pps-tools
Version: 1.0.2
Release: 4
Release: 5
Summary: User-space tools for LinuxPPS
License: GPLv2+
URL: https://github.com/redlab-i/pps-tools
Source0: https://github.com/redlab-i/pps-tools/archive/v%{version}/%{name}-%{version}.tar.gz
Patch0001: 0001-ppswatch-Fix-quitting-after-signal.patch
# https://github.com/redlab-i/pps-tools/commit/e2b25049df9a4da28168b7378016f1650d0dfa6b
Patch0002: ppsfind-Use-bin-sh-fix-possible-issues.patch
BuildRequires: gcc
@ -45,6 +47,9 @@ install -p -m644 -t $RPM_BUILD_ROOT%{_includedir}/sys timepps.h
%{_includedir}/sys/timepps.h
%changelog
* Tue Jan 02 2024 yaoxin <yao_xin001@hoperun.com> - 1.0.2-5
- ppsfind: Use /bin/sh, fix possible issues.
* Thu Oct 12 2023 liyuanyuan <liyuanyuan@xfusion.com> - 1.0.2-4
- ppswatch: Fix quitting after signal

View File

@ -0,0 +1,44 @@
From e2b25049df9a4da28168b7378016f1650d0dfa6b Mon Sep 17 00:00:00 2001
From: Alexander GQ Gerasiov <gq@cs.msu.su>
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 <gq@cs.msu.su>
---
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 <giometti@linux.it>
@@ -15,16 +15,14 @@
SYS="/sys/class/pps/"
-if [ $# -lt 1 ] ; then
+if [ $# -ne 1 ] ; then
echo "usage: ppsfind <name>" >&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