Skip to content

Bug when using --insert without --no-backup#108

Merged
ekalinin merged 1 commit intoekalinin:masterfrom
zeitounator:fix/unary_operator_bug
Feb 1, 2021
Merged

Bug when using --insert without --no-backup#108
ekalinin merged 1 commit intoekalinin:masterfrom
zeitounator:fix/unary_operator_bug

Conversation

@zeitounator
Copy link
Copy Markdown
Contributor

@zeitounator zeitounator commented Jan 30, 2021

When using the --insert option to write the TOC back to the analyzed file without using the --no-backup option, there is a bug because the no_backup variable is not set in the environment.

Example:

$ gh-md-toc --insert some_file.md 

Table of Contents
=================

   * [generated toc cut off in this example](#generated-toc-cut-off-in-this-example)
Found markers

/home/user/bin/gh-md-toc: line 180: [: =: unary operator expected
!! TOC was added into: 'some_file.md'
!! Origin version of the file: 'some_file.md.orig.2021-01-30_142030'
!! TOC added into a separate file: 'some_file.md.toc.2021-01-30_142030'

As you can see above, there is an error message about a unary operator expected on line line 180. This is because the variable is not secured with quotes for the comparison and leads to an error if not set.

This PR fixes this issue (plus secures an other line to prevent further equivalent bugs).

@zeitounator zeitounator force-pushed the fix/unary_operator_bug branch from de1ba8b to 6feec24 Compare January 30, 2021 14:06
@zeitounator zeitounator changed the title Fix for a bug when no_backup var is not set in environment Bug when using --insert **without** --no-backup Jan 30, 2021
@zeitounator zeitounator changed the title Bug when using --insert **without** --no-backup Bug when using --insert without --no-backup Jan 30, 2021
@ekalinin ekalinin merged commit d883e0b into ekalinin:master Feb 1, 2021
@ekalinin
Copy link
Copy Markdown
Owner

ekalinin commented Feb 1, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants