#!/bin/bash # Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. short_usage() { echo 'Usage: sor SNIPPET...' } help() { short_usage cat <&2 exit 1 fi eval set -- "$temp" unset temp null_terminate=false while true; do case "$1" in --help) help exit 0 ;; -0|--null) shift null_terminate=true ;; --) shift break ;; *) echo >&2 'Internal error; please report.' exit 1 ;; esac done while read_filename $null_terminate file; do for test in "$@"; do if eval "$test \"$file\""; then print_filename $null_terminate "$file" continue 2 fi done done