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

Conversion of shell script to batch file discards comments #73

Closed
rburkey2005 opened this issue Jan 15, 2025 · 3 comments
Closed

Conversion of shell script to batch file discards comments #73

rburkey2005 opened this issue Jan 15, 2025 · 3 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@rburkey2005
Copy link

The title says it all.

This occurs on Linux Mint 21.3. If you want sample code in which this occurs, I attached such a file for issue #72.

@rburkey2005
Copy link
Author

But in case it doesn't work the same way when you try it, my shell script starts with

#!/bin/bash
# This script can be used for Linux or Mac OS to perform a digital simulation
# of a single logical module, or portion thereof.  It should be executed from
# the folder containing the schematic file (module.kicad_sch) and a 
# user-created partial-testbench file called tb.v.
#
# Usage:
#       simulateModule MODULENAME [NETLISTFILE]
# where MODULENAME is one of the names of Block II AGC logic modules:
# A1, A2, A3, ..., A24.  The optional parameter can give the name of a netlist
# file.  If it is not present, then KiCad v7 or later is required so that
# we can generate the netlist file ourself from the command line.

# First, parse the command line and perform sanity checks.

if [ "$1" = "" ]
then
        echo "No module number (A1, A2, ..., A24) given"
        exit 1
else
        modulenum=$1
fi

and in the batch file this turns into

@echo off

IF "%~1" "=" "" (
  echo "No module number (A1, A2, ..., A24) given"
  exit "1"
) ELSE (
  SET "modulenum=%~1"
)

@daniel-sc
Copy link
Owner

This is no really possible based on the current stack - mainly because the parsing does not preserve comments - see: vorpaljs/bash-parser#62

@daniel-sc daniel-sc closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
@rburkey2005
Copy link
Author

It certainly seems possible, at least for full-line comments. Roughly speaking, a preprocessing step could convert full-line comments like

# This is my comment

into environment-variable assignments like

_comment_="This is my comment"

Conversion from shell-script to batch-file could then proceed normally, and afterward a postprocessing step could do the reverse conversion from

SET _comment_="This is my comment"

to

REM This is my comment

@daniel-sc daniel-sc added enhancement New feature or request help wanted Extra attention is needed labels Jan 16, 2025
@daniel-sc daniel-sc reopened this Jan 16, 2025
@daniel-sc daniel-sc self-assigned this Jan 20, 2025
daniel-sc added a commit that referenced this issue Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants