1#! /bin/sh
2
3# Copyright 2016 The Fuchsia Authors
4#
5# Use of this source code is governed by a MIT-style
6# license that can be found in the LICENSE file or at
7# https://opensource.org/licenses/MIT
8
9set -e
10
11# Alas this isn't posix.
12#set -o pipefail
13
14if [ $# -ne 1 ]
15then
16    echo "Usage: get-build-id file" >&2
17    echo "Uses \$READELF or readelf if unset."
18    exit 1
19fi
20
21READELF=${READELF:-readelf}
22FILE="$1"
23
24LC_ALL=C $READELF -n $FILE | grep -a 'Build ID:' | sed 's/.*: //g'
25