1#!/bin/sh 2# Ensure that "id" works with numeric user ids 3# Copyright (C) 2013-2023 Free Software Foundation, Inc. 4 5# This program is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see <https://www.gnu.org/licenses/>. 17 18. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 19print_ver_ id 20 21uid=$(id -u) || fail=1 22user=$(id -nu) || fail=1 23 24# Ensure the empty user spec is discarded 25returns_ 1 id '' || fail=1 26 27# Ensure we don't exit early, and process all users 28id $user > user_out || fail=1 29returns_ 1 id '' $user >multi_user_out || fail=1 30compare user_out multi_user_out || fail=1 31 32for mode in '' '-G' '-g'; do 33 id $mode $user > user_out || fail=1 # lookup name for comparison 34 35 id $mode $uid > uid_out || fail=1 # lookup name "$uid" before id "$uid" 36 compare user_out uid_out || fail=1 37 38 id $mode +$uid > uid_out || fail=1 # lookup only id "$uid" 39 compare user_out uid_out || fail=1 40done 41 42Exit $fail 43