libcros 0.5.2

A Rust library that provides easy-to-use functions for interacting with a Chrome device
Documentation
#!/bin/sh
# Copyright 2016 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Helper utility to read a single value from VPD.
#
# The script is optimized for reading one entry from VPD, first RO then RW. If
# the given key is not found, it prints nothing and exists with zero. But, it
# may emit errors in stderr, so the its users should only rely only on stdout
# and ignore stderr.

SYS_VPD=/sys/firmware/vpd

main() {
  if [ "$#" != 1 ]; then
    echo "Usage: $0 key_name" >&2
    exit 1
  fi
  local key="$1"

  for file in "${SYS_VPD}/ro/${key}" "${SYS_VPD}/rw/${key}"; do
    if [ -f "${file}" ]; then
      cat "${file}"
      return 0
    fi
  done
}
main "$@"