Cygwin inserting odd carriage returns without line breaks when running Python script

495 views Asked by At

I'm writing a Python script to interpret text files as random tables, and roll on them. The script works great when I run it from within Sublime Text. For example, here's some output from the build window in ST:

Getting random from 2500: Gold music box
Getting random from 2500: Eye patch with a mock eye set in blue sapphire and moonstone
Getting random from 2500: Fine gold chain set with a fire opal
Getting random from 2500: Embroidered silk adn velvet mantle set with numerous moonstones
Getting random from 2500: Gold music box
Getting random from H: Wand of the war mage, +3
Getting random from H: Weapon, +3
Getting random from H: Staff of frost
Getting random from CR 17 Hoard Items: Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
Getting random from CR 17 Hoard: 46000 gp, 34000 pp, and Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
46000 gp, 34000 pp, and Fine gold chain set with a fire opal, 2x Gold music box, Eye patch with a mock eye set in blue sapphire and moonstone, Embroidered silk adn velvet mantle set with numerous moonstones, Weapon, +3, Staff of frost, Wand of the war mage, +3
Number of arguments: 1 arguments.
Argument List: ['D:\\programming\\python-table-thing\\Table.py']

It also works from the Windows command prompt:

D:\programming\python-table-thing>python Table.py
Getting random from 7500: Jeweled gold crown
Getting random from E: Potion of supreme healing
Getting random from E: Potion of storm giant strength
Getting random from 8: Animal Shapes
Getting random from E: Spell scroll (Animal Shapes)
Getting random from E: Universal solvent
Getting random from CR 17 Hoard Items: Jeweled gold crown,  Spell scroll (Animal
 Shapes), Potion of storm giant strength, Potion of supreme healing, Universal s
olvent
Getting random from CR 17 Hoard: 42000 gp, 24000 pp, and Jeweled gold crown, Spe
ll scroll (Animal Shapes), Potion of storm giant strength, Potion of supreme hea
ling, Universal solvent
42000 gp, 24000 pp, and Jeweled gold crown, Spell scroll (Animal Shapes), Potion
 of storm giant strength, Potion of supreme healing, Universal solvent
Number of arguments: 1 arguments.
Argument List: ['Table.py']

But it doesn't work correctly in Cygwin (using Mintty). As near as I can tell, it looks like in Cygwin is inserting carriage returns in odd places without a line break, causing the line's ending to overwrite its beginning.

$ python Table.py
Getting random from 2500: Platinum bracelet set with a sapphire
Getting random from 2500: Jeweled anklet
Getting random from 2500:
Getting random from E: Potion of supreme healing
Getting random from E: Potion of supreme healing
Getting random from 8: Demiplane
)etting random from E: Spell scroll (Demiplane
Getting random from E: Arrow of slaying
Getting random from 9: Mass Heal
)etting random from E: Spell scroll (Mass Heal
, Arrow of slayingmiplanealingd Items: Platinum bracelet set with a sapphire
, Arrow of slayingmiplanealingd: 42000 gp, 28000 pp, and Platinum bracelet set with a sapphire
, Arrow of slayingmiplanealingum bracelet set with a sapphire
Number of arguments: 1 arguments.
Argument List: ['Table.py']

It's not just an issue with the display in the terminal, either. I tried piping it out into a file and get the same issue.

I'm assuming that this is an issue with Cygwin or Mintty, but here's the source code I'm using if you think it'll be helpful: http://pastebin.com/4bJ4LC8h

0

There are 0 answers