-
Notifications
You must be signed in to change notification settings - Fork 348
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
Add --new-script option to gmt #1481
Conversation
This option will write a modern mode script template to stdout in either bash or csh format. We could extend this to DOS batch if we can detect the Windows command window (?).
Partially addresses the issues raised in #1299. |
Yes, DOS batch should be a possible output too. On Win most of times a .bat is all one needs. |
How do we know one is running gmt under Windows command window (and want a batch) rather than in a bash shell? |
Well, under Win one should default to .bat. But we can print also the unix shebang line but commented out. Like this a Win user that wants a bash can easily uncomment that line and comment the |
I guess if Windows and if getenv ("shell") or getenv ("SHELL") are not defined then we are likely in Windows command window. What does echo %SHELL% or echo %shell% give you, if anything? |
OK, so presumably that is a good test to run under #ifdef WINDOWs and if none are set then we write a batch script. |
Improved formatting of script
See what you guys think. I cannot easily test apart from bash. |
Busy with the |
Also use the PPID instead of $$ under Windows.
Fix a few missing items in gmt.rst plus add the new-script option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I get with Windows CMD.
REM GMT modern mode batch template
REM Date: 2019-09-02T22:36:58
REM User: unknown
REM Purpose: Purpose of this script
REM Set a unique session name:
set GMT_SESSION_NAME 5372
gmt begin figurename
REMPlace modern session commands here
gmt end show
There are at least two errors here, and I've made the suggestions.
Co-Authored-By: Dongdong Tian <[email protected]>
via GetUserName function.
OK, I fixed those two. Updated gmt_putusername to work under Windows - please test. |
Needed by GetUserName
Bash on macOS:
csh on macOS:
CMD on Windows:
Git-Bash on Windows:
|
Looks good, except the username is still unknown on Windows. |
Does echo %USERNAME% give anything useful in Windows? |
Yes, %USERNAME% gives the correct username in CMD, and also $USERNAME in git-bash. |
Since GetUesrName may not always work (?).
Co-Authored-By: Dongdong Tian <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the username is correct on Windows.
Again, you wee too quick with the trigger.
A batch file should always start with a line
@echo off
Otherwise it prints all its contents which very annoying.
Also, I wouldn’t print the user not the purpose lines. It just makes the template too heavy. If user wants that type of info, let him add it.
…Sent from my iDedo
No dia 03/09/2019, às 05:15, Paul Wessel <[email protected]> escreveu:
Merged #1481 into 6.0.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub, or mute the thread.
|
This option will write a modern mode script template to stdout in either bash or csh format. We could extend this to DOS batch if we can detect the Windows command window (?). Not tested by a user whose default shell is csh or tcsh.