Skip to content

grc is buggy with the bash builtin: read -p #210

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

Open
apolopena opened this issue Mar 9, 2022 · 0 comments
Open

grc is buggy with the bash builtin: read -p #210

apolopena opened this issue Mar 9, 2022 · 0 comments

Comments

@apolopena
Copy link

apolopena commented Mar 9, 2022

Problem:

User prompts that use read -rp don't work properly with grc
See the reproduction steps for more information

Reproduction Steps:

Save the following as test.conf

# Everything
regexp=.|\.
colours="\033[38;5;38m"

Save the following as test.sh

#!/bin/bash

prompt() {
  local input question="Prompt text: Would you like do something now (y/n)?"
  while true; do
    read -rp "$question" input
    case $input in
      [Yy]* ) echo "yes was chosen"; break;;
      [Nn]* ) echo "no was choosen"; break;;
      * ) echo "Please answer y for yes or n for no.";;
    esac
  done
  return 0
}

echo "The prompt text will only display after the script terminates AND nothing else will be colorized if the -e option is used."
echo "The prompt text will not be colorzied BUT everything else will be colorized if the -s option used"
echo "The prompt text will only display after the script terminates BUT everything else will be colorized if the -e and -s options used"
echo "Everything misbehaves if there is not a delay (0.2 seconds works) added before the read call (user prompt) is made"
sleep .2 && prompt

Run the following commands and observe the behaviour each time:

  • grc -ec test.conf bash test.sh
  • grc -sc test.conf bash test.sh
  • grc -esc test.conf bash test.sh

Prompt text will only be colorized when using the -e or -s option but will only appear after the script terminates which is makes it unusable.

Omitting the -e and or the -s option(s) is a workaround but the prompt text is not colorzied.

Expected behavior

  • Prompt text should be colorized just like any other piece of text
  • when the -e option, prompt text should be colorized as expected
  • when using the -e option. prompt text should appear right away and not after the script terminates

Workarounds

Can anyone suggest anything?

Additional Information

This seems related to: #82

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

No branches or pull requests

1 participant