Skip to content

Instantly share code, notes, and snippets.

@simbo1905 simbo1905/HowTo.md
Created Apr 27, 2019

Embed
What would you like to do?
debug git-secret using bashdb and visual studio code
#!/usr/bin/env bash
# https://stackoverflow.com/a/246128/329496
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Below we source all the files, except for:
# - other opperating systems (here we assume MacOS aka OSX)
# - main.sh as we will invoke specific methods
# source ${DIR}/src/_utils/_git_secret_tools_freebsd.sh
# source ${DIR}/src/_utils/_git_secret_tools_linux.sh
source ${DIR}/src/_utils/_git_secret_tools_osx.sh
source ${DIR}/src/_utils/_git_secret_tools.sh
# source ${DIR}/src/main.sh
source ${DIR}/src/version.sh
source ${DIR}/src/commands/git_secret_whoknows.sh
source ${DIR}/src/commands/git_secret_usage.sh
source ${DIR}/src/commands/git_secret_init.sh
source ${DIR}/src/commands/git_secret_tell.sh
source ${DIR}/src/commands/git_secret_killperson.sh
source ${DIR}/src/commands/git_secret_hide.sh
source ${DIR}/src/commands/git_secret_changes.sh
source ${DIR}/src/commands/git_secret_reveal.sh
source ${DIR}/src/commands/git_secret_remove.sh
source ${DIR}/src/commands/git_secret_add.sh
source ${DIR}/src/commands/git_secret_cat.sh
source ${DIR}/src/commands/git_secret_list.sh
source ${DIR}/src/commands/git_secret_clean.sh
# change directory to where you test folder is
cd ${DIR}/test_git_checkout
# debug commands by skipping "git secret" instead just use the rest of the commands
tell "initrd@gmail.com"

How To

Install bashdb which you can do from source or get from a package manager. On MacOS you can brew install bashdb.

Install Visual Studio Code and the Bash Debug plugin from the marketplace. See this blog article yet I didn't have to do any upgrades of build from source things worked pretty much out of the box after installing bashdb via Homebrew.

Use the debug.sh script in this gist as the entrypoint to be able to step through code.

{
"version": "0.2.0",
"configurations": [
{
"name": "Bash-Debug (current file)",
"type": "bashdb",
"request": "launch",
"scriptPath": "${file}",
"commandLineArguments": "",
"windows": {
"bashPath": "C:\\Windows\\sysnative\\bash.exe"
},
"linux": {
"bashPath": "bash"
},
"osx": {
"bashPath": "bash"
}
},
{
"name": "Bash-Debug (select script from list of sh files)",
"type": "bashdb",
"request": "launch",
"scriptPath": "${command:SelectScriptName}",
"commandLineArguments": "",
"windows": {
"bashPath": "C:\\Windows\\sysnative\\bash.exe"
},
"linux": {
"bashPath": "bash"
},
"osx": {
"bashPath": "bash"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.