Code Monkey home page Code Monkey logo

Comments (5)

bkw777 avatar bkw777 commented on June 15, 2024

It's working for me on Monterey. But I see now that if I force it to use the bash that ships with osx, it doesn't work.

Please try installing bash from macports.
(Or brew, but if you don't already have a preference then I suggest macports over brew for being the more correct system despite brew being more popular, but either should work fine.)

In the mean time I'll see if it's possible to make it work with the stock bash. It's old but not that old. I didn't think I was relying on any bash 4.x features, but this thing is a tour-de-force of fancy bash tricks, so, yeah it could be some gimmicky parts are a bit too gimmicky ;)

I was thinking it sounded like maybe permissions/security settings, but when I forced it to use the stock bash just now I immediately hit one thing that is probably a fancy syntax problem not a security problem. The routine that tries to present a list of likely tty devices to pick from, fails to see the cu.* devices and falls back to listing all tty*. But under the stock bash, the cu.* devices are visible and listable, so it's probably something with the fancy way that routine uses globbing and brace expansions and array ops rather than permissions.

The only other two potential problems will be permissions to run stty on the tty device, and mkfifo to create a file in /tmp

from pdd.sh.

bkw777 avatar bkw777 commented on June 15, 2024

I'm going to make it a todo to try to downgrade the code until it works in the stock bash, because that will make it far more handy.

I might as well replace "make install" with another script too since it's a bit ridiculous to make a bash script for the purpose of having no dependencies, and then require xcode just to copy it somewhere.

from pdd.sh.

bkw777 avatar bkw777 commented on June 15, 2024

The blow-by-blow may not be exactly fascinating, but, yeah there turns out to be a lot of bash version compatibility stuff.

The first thing is right off the bat, the part that detects the OS fails. It doesn't like the ",," in "${OSTYPE,,}" which converts the value to all lower case, which makes it a little simpler to test for matches.

So because of that, it doesn't go into macos mode, and that causes the tty list to make a bad assumption that the tty is probably /dev/tty*something. That is the only reasonable fall-back assumption when all else failed, because it's not helpful to just list all device nodes (then again, maybe that's exactly what I should do in that case). Anyway this causes the problem that the /dev/cu.* devices are not presented in the list to choose from. So you end up selecting the equivalent tty.* device, but those are actually wrong you need to use the cu.* device because they are different interfaces. They both go the same port, but they work differently.

So, when you get past that by just manually specifying the right tty on the commandline...

Brians-Air:pdd.sh bkw$ DEBUG=3 pdd /dev/cu.usbserial-AL03RAXP
/usr/local/bin/pdd: line 55: ${OSTYPE,,}: bad substitution
/usr/local/bin/pdd: line 143: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
/usr/local/bin/pdd: line 214: 3F: value too great for base (error token is "3F")
/usr/local/bin/pdd: line 217: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
/usr/local/bin/pdd: line 226: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
/usr/local/bin/pdd: line 236: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
/usr/local/bin/pdd: line 343: typeset: -A: invalid option
typeset: usage: typeset [-afFirtx] [-p] name[=value] ...
/usr/local/bin/pdd: line 385: -3: substring expression < 0
Using port "/dev/cu.usbserial-AL03RAXP"
open_com()
set_stty()
stty: illegal option -- -F
usage: stty [-a|-e|-g] [-f file] [options]
stty: illegal option -- -F
usage: stty [-a|-e|-g] [-f file] [options]
PDD(opr:24, )> 

dooblydoo... lotta stuff... well, the stty illegal option is only because the unrecognized ${OSTYPE,,} means it didn't select the macos version of stty syntax. And the unrecognized typeset option is annoying but simple to change. At least I think this version of bash supports associative arrays even if not the typeset -A option...

Initial googling failed to turn up an answer about installing macports or other packages without xcode, however it does show that you don't need to install xcode just the cli tools which is a much smaller download, and they give a simple single command to run to do it, but not something clickable in the app store.

I thought there was something that worked like freebsd pkg that could install binary packages.

from pdd.sh.

bkw777 avatar bkw777 commented on June 15, 2024

Might have hit a show-stopper.
I held my nose and downgraded a few things to work in bash3 and the changes weren't too bad honestly, but now I just hit the problem that read -t # can't take a value less than 1 for timeout. It means read can't read for less than a full second timeout, which causes a couple problems, one, it will just make a lot of operations real slow, but the main problem is it's used as a replacement for /bin/sleep and needs to be able to sleep for anywhere from a few ms to a few hundred ms in many many places.

I'd rather tell the user to install bash4 or greater than to call /bin/sleep ;)
Maybe I won't mind making a whole separate alternate version of the file named "crappy_failure_pdd.sh" that has that in it. I'll have to think about this a while to try to figure out if there is any other way to polling and reading and stuff without being able to sleep for less than a whole second, or just have a fallback to use /bin/sleep if the bash is too old.

from pdd.sh.

bkw777 avatar bkw777 commented on June 15, 2024

I put my current progress into a branch named bash3 so you can follow it if you want. It's not working yet but it starts up without error and gets further along. Currently it starts and the tty selection menu is correct, no stty error, several random syntax errors fixed that you never got far enough to see yet, and when I try to ls it just times out.

from pdd.sh.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.