Fastai-nbstripout: stripping notebook outputs and metadata for git storage

Good. So I suppose you have a real bash on windows. I think whoever we made it work for last on windows, had no bash, just the command prompt. How do we tell bash env on windows - what is your SHELL environment variable - If it’s on windows? On linux it is usually set to /bin/bash.

and then can you adjust tools\trust-origin-git-config so that it generates the format that you found working, it’s most likely just this part:

is_windows = hasattr(sys, 'getwindowsversion')
cmd = "tools/fastai-nbstripout" if not is_windows else r"python tools\\\\fastai-nbstripout"

So it probably needs to be changed to:

is_windows = hasattr(sys, 'getwindowsversion')
if SHELL is in os.environ: is_windows = False
cmd = "tools/fastai-nbstripout" if not is_windows else r"python tools\\\\fastai-nbstripout"

so we pretend we are on unix if it’s bash. Except, please figure out what that condition should be so that it works for you. This is untested.

Will probably make it then into is_bash_like flag, so it’ll be more intuitive.

Thanks.


edit:

I searched on SO a bit, so this might be all you need to do the right conditional:

  1. echo $BASH # should be set for BASH

  2. What type of bash:
    https://stackoverflow.com/a/33828925/9201239
    Bash sets the shell variable OSTYPE. From man bash:

Automatically set to a string that describes the operating system on which bash is executing.

case "$OSTYPE" in
  linux*)   echo "Linux / WSL" ;;
  darwin*)  echo "Mac OS" ;; 
  win*)     echo "Windows" ;;
  msys*)    echo "MSYS / MinGW / Git Bash" ;;
  cygwin*)  echo "Cygwin" ;;
  bsd*)     echo "BSD" ;;
  solaris*) echo "Solaris" ;;
  *)        echo "unknown: $OSTYPE" ;;
esac

So you can probably get the logic right from BASH and OSTYPE env vars.

And I think we are dealing multiple types of shells on windows:

  1. Windows Bash (/ sep)
  2. Git Bash / or \ sep?
  3. not Bash /(\ sep)
  4. Cygwin bash

I guess yours is the first one.