Feature #5206

ruby -K should warn

Added by Eric Hodel over 2 years ago. Updated over 1 year ago.

[ruby-core:39025]
Status:Assigned
Priority:Normal
Assignee:Yukihiro Matsumoto
Category:core
Target version:next minor

Description

When ruby is run with -K it changes the default encoding of all files even when that may be incompatible with the source. If many libraries are used -K may cause incorrect behavior.

Now that we have the "coding:" magic comment ruby should warn if the -K flag is used and suggest that "coding:" magic comment be used instead.

Associated revisions

Revision 36274
Added by Yui NARUSE almost 2 years ago

  • ruby.c (proc_options): warn if -K option is specified. [Feature #5206]

Revision 36310
Added by Yui NARUSE almost 2 years ago

  • ruby.c (proc_options): warn only if -K and -w option is specified. see also r36274 [Feature #5206]

History

#1 Updated by Motohiro KOSAKI over 2 years ago

When ruby is run with -K it changes the default encoding of all files even when that may be incompatible with the source.  If many libraries are used -K may cause incorrect behavior.

Now that we have the "coding:" magic comment ruby should warn if the -K flag is used and suggest that "coding:" magic comment be used instead.

+1.

#2 Updated by Yusuke Endoh about 2 years ago

  • Status changed from Open to Assigned
  • Assignee set to Yui NARUSE

Naruse-san, what do you think?

Yusuke Endoh mame@tsg.ne.jp

#3 Updated by Yui NARUSE almost 2 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36274.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ruby.c (proc_options): warn if -K option is specified. [Feature #5206]

#4 Updated by Usaku NAKAMURA almost 2 years ago

  • Status changed from Closed to Assigned

I think that it is good for warning, but isn't only the time of -w option being specified?

#5 Updated by Koichi Sasada almost 2 years ago

(2012/07/03 14:46), usa (Usaku NAKAMURA) wrote:

Status changed from Closed to Assigned

I think that it is good for warning, but isn't only the time of -w option being specified?

I often use -Ks option for temporary ruby scripts because my editor's
default encoding is CP932. And I always run ruby scripts with -w option.

I'm happy if there are any other way to specify script encoding for such
disposable scripts.

--
// SASADA Koichi at atdot dot net

#6 Updated by Yui NARUSE almost 2 years ago

  • Assignee changed from Yui NARUSE to Yukihiro Matsumoto

ko1 (Koichi Sasada) wrote:

(2012/07/03 14:46), usa (Usaku NAKAMURA) wrote:

Status changed from Closed to Assigned

I think that it is good for warning, but isn't only the time of -w option being specified?

I often use -Ks option for temporary ruby scripts because my editor's
default encoding is CP932. And I always run ruby scripts with -w option.

I'm happy if there are any other way to specify script encoding for such
disposable scripts.

If ALLOWDEFAULTSOURCE_ENCODING macro is enabled, you can use --source-encoding option.

#7 Updated by Koichi Sasada almost 2 years ago

(2012/07/04 22:42), naruse (Yui NARUSE) wrote:

If ALLOWDEFAULTSOURCE_ENCODING macro is enabled, you can use --source-encoding option.

Do you mean that I should use modified ruby package instead of using
prepared package such as distributor's build or Windows installer's build?

--
// SASADA Koichi at atdot dot net

#8 Updated by Yui NARUSE almost 2 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r36310.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ruby.c (proc_options): warn only if -K and -w option is specified. see also r36274 [Feature #5206]

#9 Updated by Yui NARUSE almost 2 years ago

  • Status changed from Closed to Assigned

#10 Updated by Yui NARUSE almost 2 years ago

ko1 (Koichi Sasada) wrote:

(2012/07/04 22:42), naruse (Yui NARUSE) wrote:

If ALLOWDEFAULTSOURCE_ENCODING macro is enabled, you can use --source-encoding option.

Do you mean that I should use modified ruby package instead of using
prepared package such as distributor's build or Windows installer's build?

Or get permission from matz to add the new option.

#11 Updated by Koichi Sasada almost 2 years ago

(2012/07/05 1:02), naruse (Yui NARUSE) wrote:

Or get permission from matz to add the new option.

How about it, matz?

I think it is considerable feature with ruby-core:46021,

(*1) [ruby-trunk - Feature #6679][Open] Default Ruby
source file encoding to utf-8

--
// SASADA Koichi at atdot dot net

#12 Updated by Yusuke Endoh over 1 year ago

  • Target version set to next minor

Also available in: Atom PDF