ltsh/gettype.sh

23 lines
435 B
Bash
Raw Permalink Normal View History

2023-10-02 21:00:49 +02:00
#!/bin/sh
TYPEDB=${TYPEDB-'typedb'}
grep -Po '::\K.*$' $TYPEDB |
while read -r pattern
do
if echo "$1" |
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' |
grep -xq "${pattern}";
then
grep -A 2 -Fx "::${pattern}" $TYPEDB |
grep -m 1 -Po "$2: \K.*$" &&
echo "^-- in pattern ${pattern}" 1>&2 &&
exit
else
if [ $? -eq 2 ]; then
echo "^-- in pattern ${pattern}" 1>&2
fi
fi
done