This is a slowly growing collection of hopefully useful and reusable shell functions and patterns. https://code.jan.io/jan/jans_shell_utils
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 lines
383B

  1. # Copyright (c) 2022 Jan Lehnardt <jan@apache.org>, MIT licensed
  2. # via https://github.com/apache/couchdb/blob/1b8d4b73bc9ea67bfe0df5a41e24ea864f4c846d/rel/files/couchdb.in#L15 Apache 2 Licensed
  3. canonical_readlink () {
  4. file=$(dirname "$1")/$(basename "$1");
  5. if [ -h "file" ]; then
  6. cd $(dirname "$1")
  7. canonical_readlink $(readlink "file");
  8. else
  9. cd "${1%/*}" && pwd -P;
  10. fi
  11. }