Author Topic: Shell Copy (small bug ?)  (Read 4835 times)

0 Members and 1 Guest are viewing this topic.

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Shell Copy (small bug ?)
« on: January 21, 2022, 03:53:17 pm »
Maybe I guess it's a small bug that is good to know (find out I'm worth hours of debuggin)

Put the files in a folder, then compile and run "test_code.bas".
You will get "target.bas".

Now rename the folder, adding the "+" sign. For example from "c:\folder" to "c:\folder+"

Run again "test_code.bas".

Shell Copy doesn't work!

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Shell Copy (small bug ?)
« Reply #1 on: January 21, 2022, 04:30:22 pm »
I can't believe you are making us download 2 files with one line of code each.

Also not showing your rename code?

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: Shell Copy (small bug ?)
« Reply #2 on: January 21, 2022, 05:04:25 pm »
:) I did it so that the documentation was complete :)

Code: QB64: [Select]
  1. shell "copy " + _startdir$ + "\file.bas target.bas /y"
  2.  

The case is simple: SHELL COPY (which also has other critical issues) does NOT work if the folder in which it operates ends with the "+" sign.
I can also imagine why: the compiler, when translating from bas text, does not distinguish that "+" from a concatenation mark.
I would have needed to know because it would have saved a lot of effort.

It's not a big problem, after all it was enough to know it.

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Shell Copy (small bug ?)
« Reply #3 on: January 21, 2022, 05:05:28 pm »
It is really very stupid to give such a short code as an attachment. Next time, I will not respond to such a post at all. Here's the solution (save it as untitled.bas)

Code: QB64: [Select]
  1. a$ = "copy " + Chr$(34) + _StartDir$ + "\untitled.bas" + Chr$(34) + Chr$(32) + Chr$(34) + "target.bas" + Chr$(34)
  2.  

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Shell Copy (small bug ?)
« Reply #4 on: January 21, 2022, 05:08:13 pm »
@Petr stole the words right out of my mouth. You just need to use CHR$(34). But it isn't a bug of the compiler. You just have to enclose stuff in literal quotes sometime. I wasn't even going to respond to this at all but changed my mind when I saw that bplus and Petr both said something
Shuwatch!

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: Shell Copy (small bug ?)
« Reply #5 on: January 21, 2022, 05:15:13 pm »
Well! In this case I was not asking for a solution, I was pointing out a fact.
And "stupidly" I thought it could be useful to someone.

About the solution was intuitive. Yes, but only after understanding that "+" disturbs the interpreter. Normally why should I worry about the folder name affecting the result of the routine?

Anyway thanks for your attention.

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Shell Copy (small bug ?)
« Reply #6 on: January 21, 2022, 05:33:36 pm »
Dang, some people need to un-bunch their panties.


Well! In this case I was not asking for a solution, I was pointing out a fact.
And "stupidly" I thought it could be useful to someone.

About the solution was intuitive. Yes, but only after understanding that "+" disturbs the interpreter. Normally why should I worry about the folder name affecting the result of the routine?

Anyway thanks for your attention.

Perhaps a better title to the Topic would be "Shell Copy: something worth noting."?
Share code however you like.
At one time I was putting over 150k characters into the code box before Fellippe ask me not to, because it was bogging the site down. 😜
Granted after becoming radioactive I only have a half-life!

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: Shell Copy (small bug ?)
« Reply #7 on: January 21, 2022, 06:05:40 pm »
Maybe I play all the residual reputation (if I ever have one in here) insisting a little more.

I have been attending this forum for many years and I do not seem to have ever broken the netiquette.
I have always had words of esteem and appreciation not only for the competence but also for the human welcome and respect that you breathe.
I have never pretended to teach anything to anyone (not even to a hypothetical user who reasonably perhaps knows less than me), let alone to some of you clearly many experts.

I repeat, I thought (and frankly I still do) that sharing information (this too) was useful. Thats all!

All right... one of the cardinal principles of everything - just everything - is that no one is perfect and everyone can make mistakes.
Everybody.
Excuse my naivety.


P.S. I don't know the meaning of the idiomatic phrase at the head of Cobalt's post (in my language there is no such saying), but I assume that perhaps it is better not to know it.


P.S. 2 - Don't ban me for so little... I will still need you :)

Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Shell Copy (small bug ?)
« Reply #8 on: January 21, 2022, 09:58:16 pm »
P.S. I don't know the meaning of the idiomatic phrase at the head of Cobalt's post (in my language there is no such saying), but I assume that perhaps it is better not to know it.

It means people need to chill out and lighten up. Referring to the people complaining about your attachments when there is no need to.
Granted after becoming radioactive I only have a half-life!