I thought this worked. Many web pages tell you it works. But bash is ignoring tabs in my here docs. Worst, where there are two tabs, it is functioning as a command expand in bash, where all files in the current directory are listed to complete the command. The following is the here doc I am using. Most likely the tabs will be converted to spaces in this email. But the bottom line is, that while processing all the double tables, all the files in the current directory get listed, and the resultant file is all flush left, as if I had used the +EOF option: Thing is, I thought I tested this previously, so it is possible that there is now something wrong in my environment causing the problem? cat <<EOF>00-init.conf || exit 1 ServerAdmin $admin_email ServerName $your_host_tld <VirtualHost *:80> <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> <VirtualHost *:443> SSLEngine On SSLCertificateFile /etc/pki/tls/certs/$your_host_tld.crt SSLCertificateKeyFile /etc/pki/tls/private/$your_host_tld.key <Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> </VirtualHost> EOF thanks
On 5/5/2017 11:16 AM, Robert Moskowitz wrote:> But bash is ignoring tabs in my here docs.tab in bash is indeed filename expansion. what are 'my here' docs ? not familiar with that phrase. -- john r pierce, recycling bits in santa cruz
On 05/05/2017 02:40 PM, John R Pierce wrote:> On 5/5/2017 11:16 AM, Robert Moskowitz wrote: >> But bash is ignoring tabs in my here docs. > > tab in bash is indeed filename expansion. what are 'my here' docs ? > not familiar with that phrase. > > >A *here document* is a special-purpose code block. It uses a form of I/O redirection to feed a command list to an interactive program or a command, such as ftp, cat, or the ex text editor. Here Documents - The Linux Documentation Project <http://tldp.org/LDP/abs/html/here-docs.html> tldp.org/LDP/abs/html/here-docs.html
On Fri, May 05, 2017, Robert Moskowitz wrote:>I thought this worked. Many web pages tell you it works. But bash is >ignoring tabs in my here docs. Worst, where there are two tabs, it is >functioning as a command expand in bash, where all files in the current >directory are listed to complete the command. >.... I suspect that the shell is attempting to expand the '*' character. You need to escape the delimiter with a backslash to keep the shell from expanding: cat <<\EOF > 00-init.conf ... ... EOF>cat <<EOF>00-init.conf || exit 1 >ServerAdmin $admin_email >ServerName $your_host_tld ><VirtualHost *:80> > <Directory "/var/www/html"> > Options Indexes FollowSymLinks > AllowOverride None > Require all granted > </Directory> ></VirtualHost> ><VirtualHost *:443> > SSLEngine On > SSLCertificateFile /etc/pki/tls/certs/$your_host_tld.crt > SSLCertificateKeyFile /etc/pki/tls/private/$your_host_tld.key > <Directory "/var/www/html"> > Options Indexes FollowSymLinks > AllowOverride None > Require all granted > </Directory> ></VirtualHost> >EOF > >thanks > >_______________________________________________ >CentOS mailing list >CentOS at centos.org >https://lists.centos.org/mailman/listinfo/centos >-- Bill -- INTERNET: bill at celestial.com Bill Campbell; Celestial Software LLC URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way Voice: (206) 236-1676 Mercer Island, WA 98040-0820 Fax: (206) 232-9186 Skype: jwccsllc (206) 855-5792 The ultimate result of shielding men from the effects of folly is to fill the world with fools. -- Herbert Spencer (1891)
On 05/05/2017 03:33 PM, Bill Campbell wrote:> On Fri, May 05, 2017, Robert Moskowitz wrote: >> I thought this worked. Many web pages tell you it works. But bash is >> ignoring tabs in my here docs. Worst, where there are two tabs, it is >> functioning as a command expand in bash, where all files in the current >> directory are listed to complete the command. >> > .... > > I suspect that the shell is attempting to expand the '*' > character. You need to escape the delimiter with a backslash > to keep the shell from expanding:I tried that earlier, and \EOF did not help. And I have env variables in the here doc I need replaced. If I had to SED the file as a second step, I would have. But like I said, \EOF did not make a difference. I just tried this on a Fedora system, and got the same problem, yet: http://stackoverflow.com/documentation/bash/655/here-documents-and-here-strings#t=201705051749422129426 Gives examples with tabs in it. As does: http://tldp.org/LDP/abs/html/here-docs.html Oh, this is done through cut-n-paste. Cut from my web howto into a terminal window (screen usbtty into the Centos server). Is Terminal suppressing the tabs from the clipboard? I am using Xfce.> > cat <<\EOF > 00-init.conf ... > ... > EOF > >> cat <<EOF>00-init.conf || exit 1 >> ServerAdmin $admin_email >> ServerName $your_host_tld >> <VirtualHost *:80> >> <Directory "/var/www/html"> >> Options Indexes FollowSymLinks >> AllowOverride None >> Require all granted >> </Directory> >> </VirtualHost> >> <VirtualHost *:443> >> SSLEngine On >> SSLCertificateFile /etc/pki/tls/certs/$your_host_tld.crt >> SSLCertificateKeyFile /etc/pki/tls/private/$your_host_tld.key >> <Directory "/var/www/html"> >> Options Indexes FollowSymLinks >> AllowOverride None >> Require all granted >> </Directory> >> </VirtualHost> >> EOF >> >> thanks >> >> _______________________________________________ >> CentOS mailing list >> CentOS at centos.org >> https://lists.centos.org/mailman/listinfo/centos >>
It's certainly possible to include tabs in here documents, in shell scripts it works as expected. However, when you input the here document on the command line in an interactive shell, the moment you enter the tab it immediately triggers Bash' programmable completion and the tab never reaches the here document. To disable programmable completion (temporarily), run: bind 'set disable-completion on' To (re-)enable programmable completion, run: bind 'set disable-completion off' Robbert On 05-05-17 20:16, Robert Moskowitz wrote:> I thought this worked. Many web pages tell you it works. But bash is > ignoring tabs in my here docs. Worst, where there are two tabs, it is > functioning as a command expand in bash, where all files in the current > directory are listed to complete the command. > > The following is the here doc I am using. Most likely the tabs will be > converted to spaces in this email. But the bottom line is, that while > processing all the double tables, all the files in the current directory > get listed, and the resultant file is all flush left, as if I had used > the +EOF option: > > Thing is, I thought I tested this previously, so it is possible that > there is now something wrong in my environment causing the problem? > > cat <<EOF>00-init.conf || exit 1 > ServerAdmin $admin_email > ServerName $your_host_tld > <VirtualHost *:80> > <Directory "/var/www/html"> > Options Indexes FollowSymLinks > AllowOverride None > Require all grantedve sh > </Directory> > </VirtualHost> > <VirtualHost *:443> > SSLEngine On > SSLCertificateFile /etc/pki/tls/certs/$your_host_tld.crt > SSLCertificateKeyFile /etc/pki/tls/private/$your_host_tld.key > <Directory "/var/www/html"> > Options Indexes FollowSymLinks > AllowOverride None > Require all granted > </Directory> > </VirtualHost> > EOF > > thanks > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos
Excellent! On 05/05/2017 05:11 PM, Robbert Eggermont wrote:> It's certainly possible to include tabs in here documents, in shell > scripts it works as expected. > > However, when you input the here document on the command line in an > interactive shell, the moment you enter the tab it immediately > triggers Bash' programmable completion and the tab never reaches the > here document. > > To disable programmable completion (temporarily), run: > bind 'set disable-completion on' > To (re-)enable programmable completion, run: > bind 'set disable-completion off'This works just fine. Adds to all the sections where I have blocks with here documents with tabs, but better to turn it off and on each time, that assume it is in the right state. Again, thanks.> > Robbert > > On 05-05-17 20:16, Robert Moskowitz wrote: >> I thought this worked. Many web pages tell you it works. But bash >> is ignoring tabs in my here docs. Worst, where there are two tabs, it >> is functioning as a command expand in bash, where all files in the >> current directory are listed to complete the command. >> >> The following is the here doc I am using. Most likely the tabs will >> be converted to spaces in this email. But the bottom line is, that >> while processing all the double tables, all the files in the current >> directory get listed, and the resultant file is all flush left, as if >> I had used the +EOF option: >> >> Thing is, I thought I tested this previously, so it is possible that >> there is now something wrong in my environment causing the problem? >> >> cat <<EOF>00-init.conf || exit 1 >> ServerAdmin $admin_email >> ServerName $your_host_tld >> <VirtualHost *:80> >> <Directory "/var/www/html"> >> Options Indexes FollowSymLinks >> AllowOverride None >> Require all grantedve sh >> </Directory> >> </VirtualHost> >> <VirtualHost *:443> >> SSLEngine On >> SSLCertificateFile /etc/pki/tls/certs/$your_host_tld.crt >> SSLCertificateKeyFile /etc/pki/tls/private/$your_host_tld.key >> <Directory "/var/www/html"> >> Options Indexes FollowSymLinks >> AllowOverride None >> Require all granted >> </Directory> >> </VirtualHost> >> EOF >> >> thanks >> >> _______________________________________________ >> CentOS mailing list >> CentOS at centos.org >> https://lists.centos.org/mailman/listinfo/centos > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >