1

I have a shell script in which I use osascript to display a prompt to the user for selection from a list. The problem here is, when the script is executed via shell, the osascript window size is extended to the size of the screen height, filling the list selection with empty space. When I run the same osascript code from the script editor, the selection fits to the window size. Is there a way to make the window fit the list items (like in the second picture listed below)?

Here's the sample script:

#!/usr/bin/osascript
set magtitles to {"A", "B", "C", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "y", "Z"}
choose from list magtitles

Here's how it looks like when executed via shell:

Script started with shell

And here's how it looks like when executed via Script Editor:

Script started with Script Editor

I have tested it on Big Sur 11.1 and Big Sur 11.2 beta, both with same results.

5
  • What happens if you hold Opt & click the green dot in the larger window, then quit & re-launch? What happens if you manually shrink the window, then quit & re-launch? Apps should remember their last window size, but I'm not sure if a shell-script window will do that.
    – Tetsujin
    Commented Jan 29, 2021 at 18:19
  • Nothing changes, basically. When I run the script again it shows it the same as previously, the state is not saved.
    – VDA
    Commented Jan 29, 2021 at 18:28
  • OK, was just a thought. Sorry, idk in that case.
    – Tetsujin
    Commented Jan 29, 2021 at 18:31
  • I just tested the AppleScript osascript shell script under macOS Big Sur 11.1 and cannot replicate your issue. The dialog window opens the height of the list, showing A thru Z with no blank space under Z. Commented Jan 29, 2021 at 19:01
  • How exactly are you running the script? I have it set as "test.sh" and just execute it from the Terminal app by running "./test.sh" in the current directory. Also, which shell are you using? I tried it with both zsh and bash, it made no difference.
    – VDA
    Commented Feb 1, 2021 at 10:11

0

You must log in to answer this question.

Browse other questions tagged .