junyu-w / corgi

Corgi is a command-line workflow manager that helps with your repetitive command usages by organizing them into reusable snippet

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shell substitution command with variable setting failing.

duckie68 opened this issue · comments

I am attempting to create a command set for building a project template.

The template is a set up for creating screenplays;

  • assign template variable for the screenplay title
  • assign template variable to $TITLE
  • use shell substitution to assign template variable to $DIRECTORY changing whitespaces to underscores
  • create directory and template files using expected variables...

I'm only beginning and running into problems with the substitution.

I have tried a number of times to add single quotes or even escape sequences, all of which crash the execution before any steps take place. The best I have been able to get is assigning the first variable, followed by a bad substitution crash. Here is what at least gets that far;

{
  "title": "screenplay",
  "steps": [
    {
      "command": "export TITLE=\u003ctitle\u003e",
      "description": "set variable title"
    },
    {
      "command": "export DIRECTORY=${\u003ctitle\u003e// /_}",
      "description": "set variable directory replacing spaces with underscores"
    },
    {
      "command": "mkdir $DIRECORY $$ cd $_",
      "description": "make directory and check in"
    },
more stuff...

The output is the same if I enclose in quotes or not.

$ corgi exec screenplay
Start executing snippet "screenplay"...

Step 1: set variable title
Enter value for <title>: the big game
Running: export TITLE=the big game
[ Success ]

Step 2: set variable directory replacing spaces with underscores
Running: export DIRECTORY=${the big game// /_}
/bin/bash: DIRECTORY=${the big game// /_}: bad substitution
[ Failure ]

I am guessing this has more to do with me not understanding how to use a JSON file, but that lack on my part also means I can't be sure.

Any suggestions on what I'm doing wrong?