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

Template does not process if multiple classes exist #437

Open
kovalchik opened this issue Oct 6, 2022 · 4 comments
Open

Template does not process if multiple classes exist #437

kovalchik opened this issue Oct 6, 2022 · 4 comments
Assignees
Labels

Comments

@kovalchik
Copy link

Describe the bug

If multiple local classes are specified, templates do not seem to process or produce a file.

To reproduce

Can this be reproduced with the yadm/testbed docker image: Unknown

Steps to reproduce the behavior:

  1. Run command yadm init
  2. Run command yadm config local.class someclass
  3. Run command echo "This is a sample text" > example.txt##template
  4. Run command yadm add example.txt##template
  5. Run command yadm status
  6. Run command ls
  7. Run command rm example
  8. Run command yadm config --add local.class someotherclass
  9. Run command yadm status
  10. Run command ls

Expected behavior

The file example.txt should be created each time yadm status is run. However, the example.txt file is not created after adding the second class. The following output is seen after yadm commands, if there are two local classes:

awk: newline in string someclass
someotherclass... at source line 1

Environment

  • Operating system: MacOS 12/6
  • Version yadm: 3.2.1
  • Version Git: 2.38.0

Additional context

I was unable to reproduce this with the yadm docker image. I was unable to product any files via alternative or template files with the docker image. I assume that problem is either user error or unrelated to this issue.

@kovalchik kovalchik added the bug label Oct 6, 2022
@TheLocehiliosan TheLocehiliosan self-assigned this Oct 18, 2022
@TheLocehiliosan
Copy link
Owner

I've not been able to recreate this problem. I specifically was using version 3.2.1 and Git version 2.38.0, but on Linux. It might be some issue with the version of awk being use (based on output you mentioned)? Can let me know the output of awk --version, and if possible, could you try again using gawk/awk brew installed?

Can you doublecheck your instructions to reproduce? For example, where you write rm example, I think you probably meant rm example.txt.

Can you also show me the output of:

yadm alt

and the output of:

yadm config --get-all local.class

@kovalchik
Copy link
Author

kovalchik commented Oct 25, 2022

Installing awk through Homebrew did not resolve the issue. However, installing gawk via Homebrew did fix the issue! 🙌

Here's the outputs you asked for, in case you're still interested in trying to replicate this.

MacOS 12.6 awk version: 20200816
Homebrew awk version: 20211208
GNU Awk (gawk) version: 5.2.0

This is the output of yadm alt using the MacOS built in awk (class names have been changed to classone and classtwo for clarity):

Linking /Users/darrenk/.config/fish/functions/project_specific_functions.fish##class.classtwo to /Users/darrenk/.config/fish/functions/project_specific_functions.fish
Linking /Users/darrenk/.config/git/config.local##class.classone to /Users/darrenk/.config/git/config.local
Linking /Users/darrenk/.config/git/config.classtwo##class.classtwo to /Users/darrenk/.config/git/config.classtwo
Creating /Users/darrenk/Brewfile from template /Users/darrenk/Brewfile##template
awk: newline in string classone
classtwo... at source line 1

This is the output of yadm config --get-all local.class using the MacOS build in awk:

classone
classtwo
awk: newline in string classone
classtwo... at source line 1

@rasa
Copy link
Contributor

rasa commented Oct 26, 2022

Should

yadm/yadm

Lines 1780 to 1785 in abf6ea4

function set_awk() {
local pgm
for pgm in "${AWK_PROGRAM[@]}"; do
command -v "$pgm" &> /dev/null && AWK_PROGRAM=("$pgm") && return
done
}
read:

function set_awk() {
  local pgm
  for pgm in "${AWK_PROGRAM[@]}"; do
    command -v "$pgm" &> /dev/null && AWK_PROGRAM=("$pgm") && return
    [[ "$OSTYPE" =~ ^[Dd]arwin ]] && return # only gawk works on MacOS
  done
}

?

@TheLocehiliosan
Copy link
Owner

Should

I'm not sure. Perhaps the internal template processor can be made compatible with the MacOS awk.

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

No branches or pull requests

3 participants