Problems with multiple filenames on command line

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Problems with multiple filenames on command line

Post by john1857 »

Using Textpad 8.2, Win10, 64-bit.

I can't get multiple filenames to work on the command line.

I type:

Code: Select all

textpad x.txt y.txt
I get:

Code: Select all

OK to create 'C:\Users\john\x.txt y.txt'
If I say "yes" a file called "x.txt y.txt" is created.
According to the help file, this is the behaviour I would expect if I were using the "-u" switch.

More confusingly:
If I type:

Code: Select all

"C:\Program Files\Textpad 8"\textpad.exe x.txt
I get:

Code: Select all

OK to create 'C:\textpad.exe x.txt'
Something seems to be badly wrong with the command line parsing...
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

In Configure | Preferences | General
set Allow multiple files on the command line
and close TextPad.

The -u option just allows you to omit the quotes if a filename contains spaces.

I can't reproduce your other problem. It doesn't look like a TextPad issue.
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Post by john1857 »

ben_josephs wrote:In Configure | Preferences | General
set Allow multiple files on the command line
and close TextPad.
Thanks!
I can't reproduce your other problem. It doesn't look like a TextPad issue.
Here's a screenshot showing it happening: Image
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Post by john1857 »

ben_josephs wrote:In Configure | Preferences | General
set Allow multiple files on the command line
and close TextPad.
Thanks!
I can't reproduce your other problem. It doesn't look like a TextPad issue.
Here's a screenshot showing it happening: Image
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Post by john1857 »

ben_josephs wrote:In Configure | Preferences | General
set Allow multiple files on the command line
and close TextPad.
Thanks!
I can't reproduce your other problem. It doesn't look like a TextPad issue.
Here's a link to a screenshot showing it happening: https://www.dropbox.com/s/mlzdr1utvzz9ekz/bug.jpg?dl=0
(Can't include this as an img for some reason...)
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Ah. I just tried it with CMD (not a shell I normally use). I see what you see now. But this works:

Code: Select all

"C:\Program Files\Textpad 8\textpad.exe" x.txt
So it's a CMD bug. Who'd've thought?
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

in my opinion it is a windows bug - allowing spaces in file names ...
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

In Unix/Linux you can use almost any ASCII character in a file or directory name. The difference is that Unix/Linux people, being command-line aware, have enough sense not to do that.
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Post by john1857 »

ben_josephs wrote:Ah. I just tried it with CMD (not a shell I normally use). I see what you see now. But this works:

Code: Select all

"C:\Program Files\Textpad 8\textpad.exe" x.txt
So it's a CMD bug. Who'd've thought?
Is it really a CMD bug? I normally use 4NT ot TCMD, and they do the same thing.

I wrote a little C program to test this:

Code: Select all

#include <stdio.h>

int main(int argc, char** argv) {
  for (int i = 0; i < argc; i++) {
    printf("[%s] ",argv[i]);
  }
  printf("\n");
  return 0;
}
This is the output it produces in various test cases:

Code: Select all

C:\Users\JE\Desktop\Test dir> a.exe x y
[a.exe] [x] [y]

C:\Users\JE\Desktop\Test dir> "C:\Users\JE\Desktop\Test dir"\a.exe x y
[C:\Users\JE\Desktop\Test dir\a.exe] [x] [y]

C:\Users\JE\Desktop\Test dir> "C:\Users\JE\Desktop\Test dir\a.exe" x y
[C:\Users\JE\Desktop\Test dir\a.exe] [x] [y]
I made sure to use a directory with a space in the name. Notice that the output for the second and third cases are the same, despite the difference in quoting.

So it definitely is Not a CMD bug.[/b]
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Post by john1857 »

ben_josephs wrote:Ah. I just tried it with CMD (not a shell I normally use). I see what you see now. But this works:

Code: Select all

"C:\Program Files\Textpad 8\textpad.exe" x.txt
So it's a CMD bug. Who'd've thought?
Is it really a CMD bug? I normally use 4NT ot TCMD, and they do the same thing.

I wrote a little C program to test this:

Code: Select all

#include <stdio.h>

int main(int argc, char** argv) {
  for (int i = 0; i < argc; i++) {
    printf("[%s] ",argv[i]);
  }
  printf("\n");
  return 0;
}
This is the output it produces in various test cases:

Code: Select all

C:\Users\JE\Desktop\Test dir> a.exe x y
[a.exe] [x] [y]

C:\Users\JE\Desktop\Test dir> "C:\Users\JE\Desktop\Test dir"\a.exe x y
[C:\Users\JE\Desktop\Test dir\a.exe] [x] [y]

C:\Users\JE\Desktop\Test dir> "C:\Users\JE\Desktop\Test dir\a.exe" x y
[C:\Users\JE\Desktop\Test dir\a.exe] [x] [y]
I made sure to use a directory with a space in the name. Notice that the output for the second and third cases are the same, despite the difference in quoting.

So it definitely is NOT a cmd bug.[/b]
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Post by john1857 »

ben_josephs wrote:Ah. I just tried it with CMD (not a shell I normally use). I see what you see now. But this works:

Code: Select all

"C:\Program Files\Textpad 8\textpad.exe" x.txt
So it's a CMD bug. Who'd've thought?
Is isn't a CMD bug? I normally use 4NT or TCMD, and they do the same thing.

I wrote a little C program to test this:

Code: Select all

#include <stdio.h>

int main(int argc, char** argv) {
  for (int i = 0; i < argc; i++) {
    printf("(%s) ",*argv++);
  }
  printf("\n");
  return 0;
}
This is the output it produces in various test cases:

Code: Select all

C:\Users\JE\Desktop\Test dir> a.exe x y
(a.exe) (x) (y)

C:\Users\JE\Desktop\Test dir> "C:\Users\JE\Desktop\Test dir"\a.exe x y
(C:\Users\JE\Desktop\Test dir\a.exe) (x) (y)

C:\Users\JE\Desktop\Test dir> "C:\Users\JE\Desktop\Test dir\a.exe" x y
(C:\Users\JE\Desktop\Test dir\a.exe) (x) (y)
I made sure to use a directory with a space in the name. Notice that the output for the second and third cases are the same, despite the difference in quoting.

So it definitely is NOT a bug in CMD/4NT/TCMD.[/b]
john1857
Posts: 13
Joined: Wed Oct 09, 2019 6:02 pm

Post by john1857 »

Apologies for posting everything twice. It keeps giving me an error message when I press submit:

Code: Select all

Couldn't get mail server response codes

DEBUG MODE

Line : 185
File : smtp.php
which I thought might be due to square brackets in my test program and output, so I tried again with parentheses... it posted successfully both times despite the error message.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I use TCC (v 20), which succeded 4NT many years ago. It works as I described in my installation of TCC. (TCMD is not relevant here.)

Your C program shows that by the time the command line has been processed by the parser of your version of 4NT and your version of C run-time library, the quotes have gone.

There are other shells and other RTLs...
User avatar
AmigoJack
Posts: 532
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Post by AmigoJack »

john1857 wrote:I type:

Code: Select all

textpad x.txt y.txt
I get:

Code: Select all

OK to create 'C:\Users\john\x.txt y.txt'
Strictly speaking each program on its own can decide how to treat its command line. Most programs adhere to the space being a parameter delimiter (unless quotes are used), but there's no guarantee for you.
john1857 wrote:If I type:

Code: Select all

"C:\Program Files\Textpad 8"\textpad.exe x.txt
I get:

Code: Select all

OK to create 'C:\textpad.exe x.txt'
Again, this is the program's fault, not adhering to the common use of quotes only escaping spaces, not being seen as delimiters, too.
john1857 wrote:I wrote a little C program to test this
This already relies on a parsed command line - write a program that parses the command line itself.
Post Reply