Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert mode does not correctly work for OS X #46

Closed
col-panic opened this issue Apr 27, 2018 · 2 comments
Closed

Insert mode does not correctly work for OS X #46

col-panic opened this issue Apr 27, 2018 · 2 comments

Comments

@col-panic
Copy link

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

   * [Requirements](#requirements)
   * [Installation](#installation)
      * [Installation via Download](#installation-via-download)
      * [Installation via Docker](#installation-via-docker)
         * [Plain docker usage](#plain-docker-usage)
         * [Usage on Synology devices](#usage-on-synology-devices)
   * [Setup](#setup)
      * [Configuring the database connection](#configuring-the-database-connection)
   * [Remarks](#remarks)
      * [Demo mode login](#demo-mode-login)
date: illegal option -- -
usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
sed: 1: "/<\!--ts-->/,/<\!--te-- ...": extra characters at the end of d command
sed: 1: "Installation-and-setup.md": invalid command code I

!! TOC was added into: 'Installation-and-setup.md'
!! Origin version of the file: 'Installation-and-setup.md.orig.2018-04-27_130143'
!! TOC added into a separate file: 'Installation-and-setup.md.toc.2018-04-27_130143'
@ethanbond
Copy link

ethanbond commented May 13, 2018

Hi @col-panic, I'm not qualified to be making a PR for this (you don't want me messing with things that delete files...) but in case you're blocked, here are some changes that I made that solve this.

From line 109:

    else
        local toc=`gh_toc_md2html "$gh_src" | gh_toc_grab "$gh_src_copy"`
        echo "$toc"
        if [ "$need_replace" = "yes" ]; then
            local ts="<\!--ts-->"
            local te="<\!--te-->"
            local dt=`date +'%F_%H%M%S'`
            local ext=".orig.${dt}"
            local toc_path="${gh_src}.toc.${dt}"
            local toc_footer="<!-- Added by: `whoami`, at: `date` -->"
            # http://fahdshariff.blogspot.ru/2012/12/sed-mutli-line-replacement-between-two.html
            # clear old TOC
            local comm="/${ts}/,/${te}/{//!d;}"
            sed -i${ext} "$comm" "$gh_src"
            # create toc file
            echo "${toc}" > "${toc_path}"
            echo -e "\n${toc_footer}\n" >> "$toc_path"
            # insert toc file
            sed -i "" "/${ts}/r ${toc_path}" "$gh_src"
            echo
            echo "!! TOC was added into: '$gh_src'"
            # echo "!! Origin version of the file: '${gh_src}${ext}'"
            # echo "!! TOC added into a separate file: '${toc_path}'"
            rm "$gh_src$ext"
            rm "$toc_path"
            echo
        fi

Note that I'm removing the generated .orig and .toc files. You may not want to do that.

The relevant changes are:

  1. L121-ish: Adding a semicolon after the {//d} to {//d;} per https://stackoverflow.com/questions/6287755/using-sed-to-delete-all-lines-between-two-matching-patterns
  2. L118: Removing the date formatting to just date
  3. L127-ish: Adding an empty param "" per https://stackoverflow.com/questions/16745988/sed-command-with-i-option-in-place-editing-works-fine-on-ubuntu-but-not-mac

Hope this helps!

@col-panic
Copy link
Author

Thanks a lot guys, and thanks for your effort @ethanbond 👍

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

No branches or pull requests

2 participants