These are chat archives for bangorunix/2015

1st
Apr 2015
GeorgeKouk
@GeorgeKouk
Apr 01 2015 13:57
Little issue there that I can't find an answer whatever I search.
I have a script withing the scaffold, but when using it while being on another directory than it's own, I can't cat the README file with the -help flags
I could add the exact directory path but it would only work for me. Or add something like ~/projectDir/README.txt , I just can't make the script open the file, any hints/help would be appreciated :)
Dan Prince
@danprince
Apr 01 2015 14:28
This should be everything you need.
GeorgeKouk
@GeorgeKouk
Apr 01 2015 14:29
Thank you
Dan Prince
@danprince
Apr 01 2015 14:29
No worries
GeorgeKouk
@GeorgeKouk
Apr 01 2015 15:38
another minor question if you don't mind, in extension 2, should we make the script edit the path permanently (~/.bash_rc) or just edit the PATH for that session? Cheers
Dan Prince
@danprince
Apr 01 2015 15:40
Rather than editing the PATH, look at using ln with the -s flag in order to create a link to your script, in one of the directories that is already on the PATH.
GeorgeKouk
@GeorgeKouk
Apr 01 2015 15:41
Oh ok, thanks
Lemoncrap
@Lemoncrap
Apr 01 2015 15:53
I've got a small problem with making my script create a script, I have used if statements for the arguments such as if [ [ $1 etc.. to signify which type of scaffold the user wants however when it comes to creating the example script in the scaffold i have another if statment using the arguments again but when it's created the $1 part is always blank, i've also tried using getopts flags but that has the same outcome
Dan Prince
@danprince
Apr 01 2015 15:55
Try assigning your arguments into their own named variables such as type=$1. It'll make it easier to keep track of what's going on in that variable. Print it out at multiple steps along the way to see.
Oh, I think I slightly misunderstood your question. You mean, when it creates the new script, the $1 is always blank?
Lemoncrap
@Lemoncrap
Apr 01 2015 15:57

so in my main script i have if [[ $1 == bash ]] which uses the first argument but then in my made script which has cat > $project/bash/$project << EOF

!/bin/bash

if [[ $1 == -help ]] etc the $1 in the second script becomes bash, if i use shift it is just blank

Dan Prince
@danprince
Apr 01 2015 15:58
If you wrap your code in with three ` marks either side, it will format it in Gitter.
if [[ $1 == bash ]]
For example
Lemoncrap
@Lemoncrap
Apr 01 2015 15:59
cat > $project/bash/$project << EOF !/bin/bash if [[ $1 == -help ]] then cat README.txt fi EOF
Dan Prince
@danprince
Apr 01 2015 16:00
What do you mean by, 'if I use shift'?
Lemoncrap
@Lemoncrap
Apr 01 2015 16:00
So i want my main project script to create another script in the other directory with arguments, but the $1 in the secondary script always becomes bash which was what input in the main script... if that makes sense, it's hard to explain
GeorgeKouk
@GeorgeKouk
Apr 01 2015 16:01
use the \ for special characters
Lemoncrap
@Lemoncrap
Apr 01 2015 16:01
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_07.html Tried using this to shift the arguments and remove the old $1 but that just makes it blank
Dan Prince
@danprince
Apr 01 2015 16:01
Yeah, ok. If you scroll back up through this room, I had a conversation with @agwhitaker93 about the same thing happening.
Lemoncrap
@Lemoncrap
Apr 01 2015 16:02
ohh, my bad, i'll do it that way instead then
thanks for the help
Dan Prince
@danprince
Apr 01 2015 16:03
That's ok
scottyblizz
@scottyblizz
Apr 01 2015 16:16
thanks for the update on blackboard guys, much clearer!
Dan Prince
@danprince
Apr 01 2015 16:17
Glad it helped!
GeorgeKouk
@GeorgeKouk
Apr 01 2015 16:47
I used the ln -s you suggested Dan, the new scripts can be run global as a command, but because I use a link, the README file cannot be found by the script as it thinks it runs on usr/local/bin ... Is there a workaround or should I add the location to the PATH instead?
Dan Prince
@danprince
Apr 01 2015 16:50
You have a couple of options, you can either move the README to somewhere else and use an absolute path, or you can modify the deploy script so that it works out where it's deploying from and looks back to there from /usr/local/bin
To clarify, both options should be done using the deploy script, rather than by hand
Lemoncrap
@Lemoncrap
Apr 01 2015 17:24
Would you be able to make it so we can resubmit our work on blackboard if we have already submitted? I've made a few changes so was hoping i could resubmit
scottyblizz
@scottyblizz
Apr 01 2015 17:44
if some of the extensions change/remove some of our original code from the "core" assessment, is that ok?
Dan Prince
@danprince
Apr 01 2015 18:28
@Lemoncrap You should be able to resubmit now
@scottyblizz So long as it doesn't break any earlier functionality, that's fine
If it changes the way it works, then those changes need to be documented in the README
scottyblizz
@scottyblizz
Apr 01 2015 18:32
ah ok thanks :)