瀏覽代碼

Add Bash Safe Parent Dir

Schnippet to safely get the parent directory of a Bash script.
master
Nate Bohman 3 年之前
父節點
當前提交
41969752d8
簽署人: Nate Bohman <natrinicle@gmail.com> GPG 金鑰 ID: C10546A54ABA1CE5
共有 1 個檔案被更改,包括 6 行新增0 行删除
  1. +6
    -0
      bash_parent_dir.sh

+ 6
- 0
bash_parent_dir.sh 查看文件

@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Get the parent dir to the one this script is located in.
base_dir=$(dirname -- "$(dirname -- "$(realpath -- "${0}")")")

echo "${base_dir}"

Loading…
取消
儲存