Skip to content

Commit 4c36fc3

Browse files
committed
fix: space contains in username
1 parent 9afb4ee commit 4c36fc3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

.vscode/env.zsh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ function safe_name() {
5858
echo "Usage: safe_name <name>"
5959
return 1
6060
fi
61-
echo "$name" | tr '@$.-' '____' # replace . and - with _ to avoid env var issues
61+
echo "$name" | tr '@$.- ' '_____' # replace . and - with _ to avoid env var issues
6262
}
6363

6464
function update_host_to_env() {
6565
if [[ -x "$(command -v yq)" && -d "${PROJECT_FOLDER}/hosts" ]]; then
66-
for ur in $(ls -1 ${PROJECT_FOLDER}/hosts); do
67-
local file="${PROJECT_FOLDER}/hosts/${ur}/${ur}.md"
66+
for ur in ${(@f)"$(ls -1 ${PROJECT_FOLDER}/hosts)"}; do
67+
local file="'${PROJECT_FOLDER}/hosts/${ur}/${ur}.md'"
6868
if [ -f "$file" ]; then
6969
local host_data=$(cut_lines_from_markdown_codes "$file" "yaml host")
7070

@@ -123,8 +123,8 @@ function set_current_host() {
123123
# auto set the data in the
124124
function update_user_cred_to_env() {
125125
if [[ -x "$(command -v yq)" && -d "${PROJECT_FOLDER}/users" ]]; then
126-
for ur in $(ls -1 ${PROJECT_FOLDER}/users); do
127-
local file="${PROJECT_FOLDER}/users/${ur}/${ur}.md"
126+
for ur in ${(@f)"$(ls -1 ${PROJECT_FOLDER}/users)"}; do
127+
local file="'${PROJECT_FOLDER}/users/${ur}/${ur}.md'"
128128
if [ -f "$file" ]; then
129129
local usercred=$(cut_lines_from_markdown_codes "$file" "yaml credentials")
130130

@@ -171,7 +171,7 @@ function set_current_user() {
171171

172172
### auto invoke the commands in markdown files
173173
function auto_invoker() {
174-
for markdown in $(find ${PROJECT_FOLDER}/{users,hosts,services} -iname "*.md" 2>/dev/null); do
174+
for markdown in ${(@f)"$(find ${PROJECT_FOLDER}/{users,hosts,services} -iname "*.md" 2>/dev/null)"}; do # list all markdown files in users, hosts, services
175175
local auto_invoker=$(cut_lines_from_markdown_codes "$markdown" "zsh env-invoked")
176176
if [[ -n "$auto_invoker" ]]; then
177177
source <(echo "$auto_invoker") # source it!

0 commit comments

Comments
 (0)