kaushalmodi / .emacs.d

My emacs configuration
MIT License
261 stars 49 forks source link

Add bash version of git_force_update.csh #20

Closed kaushalmodi closed 8 years ago

kaushalmodi commented 8 years ago

https://github.com/kaushalmodi/.emacs.d/pull/19

hhnr commented 8 years ago

any reason you are using csh script in the first place?

kaushalmodi commented 8 years ago

@rdotdk work

hhnr commented 8 years ago

Work laptop? Okay. Let me guess RHEL?

kaushalmodi commented 8 years ago

Work laptop?

Sort of, virtual machine.

RHEL?

Yup

kaushalmodi commented 8 years ago

I went ahead and replaced git_force_update.csh with force_update_emacsd.sh.

https://github.com/kaushalmodi/.emacs.d/commit/646b859885f7980624e4504372540fd844adb8a3

In tcsh, I use this alias:

alias update_emacs_config '(set e="/tmp/${USER}_force_update_emacsd.sh" \\
                           && curl https://raw.githubusercontent.com/kaushalmodi/.emacs.d/master/force_update_emacsd.sh >! $e \\
                           && chmod 0755 $e \\
                           && $e \!:1)'
hhnr commented 8 years ago

@kaushalmodi the script seems to fail with ./force_update_emacsd.sh: [[: not found error. I think the first line #!/bin/sh should be #!/bin/bash.

kaushalmodi commented 8 years ago

@rdotdk Thanks for trying. RHEL probably has sh symlinked to bash. So I didn't notice it. Let me see if I can use [ instead of [[. If not, will change the shebang to bash.

kaushalmodi commented 8 years ago

RHEL probably has sh symlinked to bash.

Of course it is :)

> sh --version       
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
kaushalmodi commented 8 years ago

As I cannot try the "real sh" on my system, I am going with what you suggested.

@rdotdk Try out after updating to https://github.com/kaushalmodi/.emacs.d/commit/cc6e09dd5fcc863bb7d7d16dc2c5325e98693875

hhnr commented 8 years ago

Works without any errors. Tested with bash on Ubuntu system.

RHEL probably has sh symlinked to bash.

In case of debian based systems it is symlinked to dash.

hari@hari-laptop:~$ ll /bin/sh
lrwxrwxrwx 1 root root 4 Nov  1 10:31 /bin/sh -> dash*
kaushalmodi commented 8 years ago

Works without any errors. Tested with bash on Ubuntu system.

Thanks for confirming!

kaushalmodi commented 8 years ago

Note to self: Never use #!/bin/sh in shebangs.

hhnr commented 8 years ago

Yes. Also the paths shouldn't be mentioned directly in the shebang, instead #!/usr/bin/env bash should be used for portability.

kaushalmodi commented 8 years ago

Thanks, I was almost going to do that as I do the same for perl. I assumed that bash would be fine.

But there you go ( https://github.com/kaushalmodi/.emacs.d/commit/bd1131207035c3cf2032e78651febeea6e71e469 ). I cannot not do the right thing. :)