You are not logged in.

#1 2006-04-27 08:23:25

riwa
Member
From: Lund, Sweden
Registered: 2006-04-04
Posts: 215

# not always comment in script?

It's probably a stupid question but reading through wiki about configuring and securing ssh/sshd it tells me to change commented lines and keeps them commented in the examples. I guess I should uncomment the lines but I wanted the opportunity to ask this at the same time. Are there exceptions to the comment rule (except for RE)? In that case which are they and how do I recognise them? I mean:

#MaxStartups 10

Must be a comment in every occasion right?

/Richard


If you must have must. Have must.
- DKE supporters about this wonderful swedish soda.

Offline

#2 2006-04-27 13:06:11

FUBAR
Member
From: Belgium
Registered: 2004-12-08
Posts: 1,029
Website

Re: # not always comment in script?

So far I haven't come across a script or config file where # wasn't a comment.


A bus station is where a bus stops.
A train station is where a train stops.
On my desk I have a workstation.

Offline

#3 2006-04-27 19:39:26

stingray
Member
From: Lima, Peru SA
Registered: 2006-03-24
Posts: 188

Re: # not always comment in script?

Here is a thought, I'm new to linux scripts...

#!/bin/bash

This is a comment, but some editors, prosseses, etc. watch for it to know how to handle the file.  But in reality, it is still just a comment?

Offline

#4 2006-04-27 19:58:22

riwa
Member
From: Lund, Sweden
Registered: 2006-04-04
Posts: 215

Re: # not always comment in script?

It's called a sha-bang and indicates which interpreter will be used to run the program.


If you must have must. Have must.
- DKE supporters about this wonderful swedish soda.

Offline

#5 2006-04-28 01:10:51

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: # not always comment in script?

No, the rule isn't "# Something" must be a comment in every occasion - # is used for a comment in shell scripts, sure, but config files could easily have some sort of proprietary setup where comments are something completely different.

If you're not sure, ask the developers of the app how to insert comments into the config file.

Offline

#6 2006-04-28 01:59:54

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 794
Website

Re: # not always comment in script?

The real lesson here is that every language could have a different way to mark comments.  Most shells use #, C++ is // and /* */, Lua is --, .Xdefaults is !, and there are tons of other examples.

Most config files do use # as a comment, but you really need to learn more about programming languages and applications.  There are no concrete rules here.

Offline

#7 2006-04-28 06:33:26

riwa
Member
From: Lund, Sweden
Registered: 2006-04-04
Posts: 215

Re: # not always comment in script?

I'm referring to bash here. All regular scripts in arch are written in bash no? It's the ssh_config and the sshd_config files. I found a man page where it said that:

wiki-pages wrote:

Empty lines and lines starting with `#' are comments.

Problem solved, however, shouldn't I assume that any "regular" script with a line starting with # is really a comment?


If you must have must. Have must.
- DKE supporters about this wonderful swedish soda.

Offline

#8 2006-04-28 08:34:44

codemac
Member
From: Cliche Tech Place
Registered: 2005-05-13
Posts: 794
Website

Re: # not always comment in script?

You should only assume that if a script starts with:

#!/bin/bash

or any other known shell.

If by "regular" you mean bash, then yes.

Offline

#9 2006-04-28 15:50:38

Bison
Member
From: Jacksonville, FL
Registered: 2006-04-12
Posts: 158
Website

Re: # not always comment in script?

I thought I recalled the php.ini being commented with ';'.

Offline

#10 2006-04-29 10:18:24

riwa
Member
From: Lund, Sweden
Registered: 2006-04-04
Posts: 215

Re: # not always comment in script?

Ok thanks. Just needed to know the standards so I don't mess up things without knowing it. But I recall that .bashrc and similiar files do not start with a sha-bang. Aren't these bash scripts?


If you must have must. Have must.
- DKE supporters about this wonderful swedish soda.

Offline

#11 2006-04-29 10:38:10

shbang
Member
Registered: 2005-10-03
Posts: 76

Re: # not always comment in script?

.bashrc is an initialization file that bash will execute commands from if an interactive shell is started (and no options are present to prevent it or change where initialization commands are executed from)

man 1 bash

Offline

#12 2006-05-24 02:32:51

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: # not always comment in script?

It all just depends on what file you are editing, for config files

#

are usually used for commenting, but on alot of languages the comment operator may var from alnguage to language. All you simply got to mainly do is become firmiliar with different programming languages syntax, that way you'll know what the comment operator for that language.

Offline

Board footer

Powered by FluxBB