Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use author env variable if set #218

Closed
wants to merge 1 commit into from

Conversation

keiravillekode
Copy link
Contributor

bin/create-exercise now uses the author environment variable, if set, instead of requesting github handle.

A few other tracks already use this approach.

@@ -22,8 +22,13 @@ while [[ ${pascal} =~ (.*)-(.*) ]]; do
pascal=${BASH_REMATCH[1]}${BASH_REMATCH[2]^}
done

if [[ -z $author ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how $author is initialized, unless it's an environment variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read is a builtin command that sets environment variables.

read -rp "What's your GitHub handle? "

sets REPLY

read -rp "What's your GitHub handle? " author

sets author

https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html#index-read

https://www.computerhope.com/unix/bash/read.htm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other tracks using this same environment variable:

8th/bin/add-exercise:    read -rp 'Your github username: ' author
arm64-assembly/bin/create-exercise:    read -rp "What's your github username? " author
idris/bin/create-exercise.sh:    read -rp "What's your github username? " author
jq/bin/add-exercise:read -rp 'Your github username: ' author
julia/bin/add-practice-exercise:    read -rp 'Your GitHub username: ' author
mips/bin/create-exercise:    read -rp "What's your github username? " author
r/bin/add-practice-exercise:    read -rp 'Your GitHub username: ' author
roc/bin/add-exercise:    read -rp 'Your github username: ' author
vlang/bin/bootstrap_practice_exercise.sh:    read -rp "What's your github username? " author
x86-64-assembly/bin/create-exercise:    read -rp "What's your github username? " author

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Believe me, I'm well aware how read works. I'm talking about line 25: [[ -z $author ]] -- when will the variable ever not be empty at line 25? I'm questioning the purpose of this PR.

BTW read does not set environment variables, it sets a shell variable. It's up to export or declare -x to make it available in the environment. This is a pet peeve of mine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I understand the question better now.

Before many tracks had bin/create-exercise scripts, I write my own for each track I was contributing to, that would copy in track-specific files and update .meta/config.json with my github handle.

Now that many tracks have scripts, I should use those. My concern is that I might mistype my github handle. So I set author in my .profile.

It isn't important, we don't need this PR.

Copy link
Contributor

@glennj glennj Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. In some of the other "create exercise" scripts I've written, I provided the ability to pass the author name by options: ./bin/create_exercise -a glennj forth. Is that something you'd be interested in? You could write create_exercise -a $author $slug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That would be excellent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants