Skip to content

sed Error leads to file loss #26

Description

@AndrewDDavis

When running subedit -c on Debian Linux, I got the following output:

Cleaning "Moviename.en.Adjusted.srt"
sed: -e expression #28, char 44: Invalid collation character
iconv: conversion stopped due to problem in writing the output: Broken pipe
/usr/local/bin/subedit: line 849: temp3arraysrt: bad array subscript
/usr/local/bin/subedit: line 855: temp3arraysrt: bad array subscript
/usr/local/bin/subedit: line 861: temp3arraysrt: bad array subscript
/usr/local/bin/subedit: line 867: temp3arraysrt: bad array subscript
/usr/local/bin/subedit: line 873: temp3arraysrt: bad array subscript
/usr/local/bin/subedit: line 879: temp3arraysrt: bad array subscript
/usr/local/bin/subedit: line 3904: temp1arraysrt: bad array subscript
/usr/local/bin/subedit: line 3905: unset: [-1]: bad array subscript
sed: -e expression #3, char 135: Invalid collation character

Due to the "problem in writing the output" line, the contents of the file were lost.

I suspected a problem with LC_COLLATE, which I have set to C.utf8. Running the command in the following way caused subedit to run without errors, so subedit should probably set its own LC variables internally:

LC_ALL=C subedit -c ...

I would additionally suggest that it's a safer strategy to have subedit write to a temporary file, then only overwrite the input file if the commands succeeded without error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions